-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Delete Landscape with Data Objects or Capabilities
Fix #148
- Loading branch information
1 parent
c6afc0f
commit dc8b4c6
Showing
8 changed files
with
348 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/test/java/com/mauvaisetroupe/eadesignit/service/importfile/DeleteLandscapeWithCapa.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.mauvaisetroupe.eadesignit.service.importfile; | ||
|
||
import static org.junit.Assert.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.mauvaisetroupe.eadesignit.domain.CapabilityApplicationMapping; | ||
import com.mauvaisetroupe.eadesignit.domain.LandscapeView; | ||
import com.mauvaisetroupe.eadesignit.repository.ApplicationRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.CapabilityApplicationMappingRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.DataObjectRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.FunctionalFlowRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.LandscapeViewRepository; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import org.apache.poi.EncryptedDocumentException; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
public class DeleteLandscapeWithCapa { | ||
|
||
@Autowired | ||
Mockservice mockservice; | ||
|
||
@Autowired | ||
LandscapeViewRepository landscapeViewRepository; | ||
|
||
@Autowired | ||
ApplicationRepository applicationRepository; | ||
|
||
@Autowired | ||
FunctionalFlowRepository functionalFlowRepository; | ||
|
||
@Autowired | ||
CapabilityApplicationMappingRepository capabilityApplicationMappingRepository; | ||
|
||
@Autowired | ||
DataObjectRepository dataObjectRepository; | ||
|
||
@Autowired | ||
JdbcTemplate jdbcTemplate; | ||
|
||
@Test | ||
@Transactional(propagation = Propagation.NOT_SUPPORTED) | ||
void testDeleteLandscapeWithCapabilities() throws EncryptedDocumentException, IOException { | ||
assertEquals(0, applicationRepository.findAll().size()); | ||
assertEquals(0, landscapeViewRepository.findAll().size()); | ||
assertEquals(0, functionalFlowRepository.findAll().size()); | ||
|
||
// Create Landscape, load Capabilities | ||
mockservice.createLandscape(); | ||
mockservice.createCapailitiesAndMapping("CPB.01"); | ||
|
||
checkNbCapabilityMappings(9); | ||
|
||
LandscapeView flw01 = landscapeViewRepository.findByDiagramNameIgnoreCase("Invest Landscape"); | ||
mockservice.deleteLandscape(flw01.getId()); | ||
|
||
checkNbCapabilityMappings(0); | ||
|
||
flw01 = landscapeViewRepository.findByDiagramNameIgnoreCase("Invest Landscape"); | ||
assertNull(flw01); | ||
|
||
mockservice.createLandscape(); | ||
mockservice.createCapailitiesAndMapping("CPB.01"); | ||
mockservice.createCapailitiesAndMapping("CPB.02"); | ||
checkNbCapabilityMappings(10); | ||
|
||
flw01 = landscapeViewRepository.findByDiagramNameIgnoreCase("Invest Landscape"); | ||
mockservice.deleteLandscape(flw01.getId()); | ||
|
||
checkNbCapabilityMappings(2); | ||
} | ||
|
||
protected void checkLandscapeMapping(String landscapeName, int expectedCapabilityMappingNb) { | ||
LandscapeView flw01 = landscapeViewRepository.findByDiagramNameIgnoreCase(landscapeName); | ||
landscapeViewRepository.save(flw01); | ||
assertEquals(expectedCapabilityMappingNb, flw01.getCapabilityApplicationMappings().size()); | ||
} | ||
|
||
protected List<CapabilityApplicationMapping> checkNbCapabilityMappings(int nbMappings) { | ||
List<CapabilityApplicationMapping> applicationMappings = capabilityApplicationMappingRepository.findAll(); | ||
assertEquals(nbMappings, applicationMappings.size()); | ||
return applicationMappings; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
.../java/com/mauvaisetroupe/eadesignit/service/importfile/DeleteLandscapeWithDatObjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.mauvaisetroupe.eadesignit.service.importfile; | ||
|
||
import static org.junit.Assert.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.mauvaisetroupe.eadesignit.domain.LandscapeView; | ||
import com.mauvaisetroupe.eadesignit.repository.ApplicationRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.CapabilityApplicationMappingRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.DataObjectRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.FunctionalFlowRepository; | ||
import com.mauvaisetroupe.eadesignit.repository.LandscapeViewRepository; | ||
import java.io.IOException; | ||
import org.apache.poi.EncryptedDocumentException; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
public class DeleteLandscapeWithDatObjects { | ||
|
||
@Autowired | ||
Mockservice mockservice; | ||
|
||
@Autowired | ||
LandscapeViewRepository landscapeViewRepository; | ||
|
||
@Autowired | ||
ApplicationRepository applicationRepository; | ||
|
||
@Autowired | ||
FunctionalFlowRepository functionalFlowRepository; | ||
|
||
@Autowired | ||
CapabilityApplicationMappingRepository capabilityApplicationMappingRepository; | ||
|
||
@Autowired | ||
DataObjectRepository dataObjectRepository; | ||
|
||
@Autowired | ||
JdbcTemplate jdbcTemplate; | ||
|
||
@Test | ||
@Transactional(propagation = Propagation.NOT_SUPPORTED) | ||
void testDeleteLandscapeWithDataObject() throws EncryptedDocumentException, IOException { | ||
assertEquals(0, landscapeViewRepository.findAll().size()); | ||
assertEquals(0, functionalFlowRepository.findAll().size()); | ||
|
||
// Create Landscape, load Capabilities | ||
mockservice.createLandscape(); | ||
mockservice.createDataObjects(); | ||
|
||
mockservice.checkNBDataObjects("Invest Landscape", 6); | ||
checkNbDataObjects(11); | ||
|
||
LandscapeView flw01 = landscapeViewRepository.findByDiagramNameIgnoreCase("Invest Landscape"); | ||
mockservice.deleteLandscape(flw01.getId()); | ||
|
||
flw01 = landscapeViewRepository.findByDiagramNameIgnoreCase("Invest Landscape"); | ||
assertNull(flw01); | ||
//DataObjects not deleted when deleting Landscape due to parent relationship complexity | ||
checkNbDataObjects(11); | ||
|
||
mockservice.createLandscape(); | ||
mockservice.createDataObjects(); | ||
|
||
checkNbDataObjects(11); | ||
} | ||
|
||
protected void checkNbDataObjects(int expected) { | ||
assertEquals(expected, dataObjectRepository.findAll().size()); | ||
} | ||
} |
Oops, something went wrong.