@Test public void testRemoveFromRoleDescriptor() { RoleDescriptor roleDescriptor = new RoleDescriptor(); roleDescriptor.setName(NAME); roleDescriptor.setDescription(DESCRIPTION); roleDescriptor.setPrefix(PREFIX); roleDescriptor.setIsPlanned(IS_PLANNED); roleDescriptor.setHasMultipleOccurrences(HAS_MULTIPLE_OCCURENCES); roleDescriptor.setIsOptional(IS_OPTIONAL); this.taskDescriptor.addAdditionalRole(roleDescriptor); assertTrue(this.taskDescriptor.getAdditionalRoles().size() == 1); assertTrue(roleDescriptor.getAdditionalTasks().size() == 1); this.taskDescriptor.removeAdditionalRole(roleDescriptor); assertTrue(this.taskDescriptor.getAdditionalRoles().isEmpty()); assertTrue(roleDescriptor.getAdditionalTasks().isEmpty()); }
@Test public void testAddToMainRole() { RoleDescriptor roleDescriptor = new RoleDescriptor(); roleDescriptor.setName(NAME); roleDescriptor.setDescription(DESCRIPTION); roleDescriptor.setPrefix(PREFIX); roleDescriptor.setIsPlanned(IS_PLANNED); roleDescriptor.setHasMultipleOccurrences(HAS_MULTIPLE_OCCURENCES); roleDescriptor.setIsOptional(IS_OPTIONAL); this.taskDescriptor.addMainRole(roleDescriptor); assertNotNull(this.taskDescriptor.getMainRole()); assertTrue(roleDescriptor.getPrimaryTasks().size() == 1); }
@Test public void testRemoveFromAllRoleDescriptors() { RoleDescriptor rd1 = new RoleDescriptor(); rd1.setName("otherName"); rd1.setDescription("otherDescription"); rd1.setPrefix(PREFIX); rd1.setIsPlanned(IS_PLANNED); rd1.setHasMultipleOccurrences(HAS_MULTIPLE_OCCURENCES); rd1.setIsOptional(IS_OPTIONAL); RoleDescriptor rd2 = new RoleDescriptor(); rd2.setName(NAME); rd2.setDescription(DESCRIPTION); rd2.setPrefix(PREFIX); rd2.setIsPlanned(IS_PLANNED); rd2.setHasMultipleOccurrences(HAS_MULTIPLE_OCCURENCES); rd2.setIsOptional(IS_OPTIONAL); Set<RoleDescriptor> roledescriptors = new HashSet<RoleDescriptor>(); roledescriptors.add(rd1); roledescriptors.add(rd2); this.taskDescriptor.addAllAdditionalRoles(roledescriptors); assertTrue(rd1.getAdditionalTasks().size() == 1); assertTrue(rd2.getAdditionalTasks().size() == 1); assertTrue(this.taskDescriptor.getAdditionalRoles().size() == 2); this.taskDescriptor.removeAllAdditionalRoles(); assertTrue(rd1.getAdditionalTasks().isEmpty()); assertTrue(rd2.getAdditionalTasks().isEmpty()); assertTrue(this.taskDescriptor.getAdditionalRoles().isEmpty()); }