public CopyUnit(ResourceEntity originResource, ResourceEntity targetResource, CopyResourceDomainService.CopyMode mode, ForeignableOwner actingOwner) throws AMWException { Map<CopyResourceDomainService.CopyMode, Set<ForeignableOwner>> validCopyModeOwnerCombinations = CopyHelper.getValidModeOwnerCombinationsMap(); for (CopyResourceDomainService.CopyMode copyMode : validCopyModeOwnerCombinations.keySet()) { if (mode == copyMode && !validCopyModeOwnerCombinations.get(copyMode).contains(actingOwner)) { throw new AMWException("Copy in " + mode.name() + " mode can not be executed by owner " + actingOwner); } } this.targetResource = targetResource; this.originResource = originResource; this.mode = mode; this.actingOwner = actingOwner; this.result = new CopyResourceResult(targetResource != null ? targetResource.getName() : null); }
@Test public void test_getCopy() throws AMWException { Map<CopyResourceDomainService.CopyMode, Set<ForeignableOwner>> validModeOwnerCombinationsMap = CopyHelper.getValidModeOwnerCombinationsMap(); for (CopyResourceDomainService.CopyMode copyMode : validModeOwnerCombinationsMap.keySet()) { for (ForeignableOwner actingOwner : validModeOwnerCombinationsMap.get(copyMode)) { shouldCopyTemplateDescriptor_emptyTarget(copyMode, actingOwner); shouldCopyTemplateDescriptor(copyMode, actingOwner); } } }
@Test public void test_getCopy() throws AMWException { Map<CopyResourceDomainService.CopyMode, Set<ForeignableOwner>> validModeOwnerCombinationsMap = CopyHelper .getValidModeOwnerCombinationsMap(); for (CopyResourceDomainService.CopyMode copyMode : validModeOwnerCombinationsMap.keySet()) { for (ForeignableOwner actingOwner : validModeOwnerCombinationsMap.get(copyMode)) { shouldCopyMasterRelations_emptyTarget(copyMode, actingOwner); shouldCopyMasterRelations_existingTarget(copyMode, actingOwner); shouldCopySlaveRelations_emptyTarget(copyMode, actingOwner); shouldCopySlaveRelations_existingTarget(copyMode, actingOwner); } } }
@Test public void test_getCopy() throws AMWException { Map<CopyResourceDomainService.CopyMode, Set<ForeignableOwner>> validModeOwnerCombinationsMap = CopyHelper .getValidModeOwnerCombinationsMap(); for (CopyResourceDomainService.CopyMode copyMode : validModeOwnerCombinationsMap.keySet()) { for (ForeignableOwner actingOwner : validModeOwnerCombinationsMap.get(copyMode)) { shouldCopyMasterRelations_emptyTarget(copyMode, actingOwner); shouldCopyMasterRelations_existingTarget(copyMode, actingOwner); shouldCopySlaveRelations_emptyTarget(copyMode, actingOwner); shouldCopySlaveRelations_existingTarget(copyMode, actingOwner); shouldCopyApplicationRelations(copyMode, actingOwner); } } }
@Test public void test_copyPropertyEntity() throws AMWException { Map<CopyResourceDomainService.CopyMode, Set<ForeignableOwner>> validCopyModeOwnerCombinations = CopyHelper.getValidModeOwnerCombinationsMap(); for (CopyResourceDomainService.CopyMode copyMode : validCopyModeOwnerCombinations.keySet()) { for(ForeignableOwner foreignableOwner : validCopyModeOwnerCombinations.get(copyMode)){ ResourceEntity originResource = new ResourceEntityBuilder().mockAppServerEntity("originResource", null, null, null); when(originResource.isDeletable()).thenReturn(true); ResourceEntity targetResource = new ResourceEntityBuilder().buildAppServerEntity("targetResource", null, null, true); CopyUnit copyUnit = new CopyUnit(originResource, targetResource, copyMode, foreignableOwner); copyPropertyEntity_targetNull(copyUnit); copyPropertyEntity(copyUnit); } } }