List of usage examples for java.util Set clear
void clear();
From source file:com.netflix.genie.core.jpa.services.JpaApplicationServiceImplIntegrationTests.java
/** * Test the get applications method.//w w w. jav a 2s . com */ @Test public void testGetApplicationsByTags() { final Set<String> tags = Sets.newHashSet("prod"); Page<Application> apps = this.appService.getApplications(null, null, null, tags, null, PAGEABLE); Assert.assertEquals(3, apps.getNumberOfElements()); Assert.assertEquals(APP_3_ID, apps.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_2_ID, apps.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_1_ID, apps.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new)); tags.add("yarn"); apps = this.appService.getApplications(null, null, null, tags, null, PAGEABLE); Assert.assertEquals(1, apps.getNumberOfElements()); Assert.assertEquals(APP_2_ID, apps.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); tags.clear(); tags.add("genie.name:spark"); apps = this.appService.getApplications(null, null, null, tags, null, PAGEABLE); Assert.assertEquals(1, apps.getNumberOfElements()); Assert.assertEquals(APP_2_ID, apps.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); tags.add("somethingThatWouldNeverReallyExist"); apps = this.appService.getApplications(null, null, null, tags, null, PAGEABLE); Assert.assertTrue(apps.getNumberOfElements() == 0); tags.clear(); apps = this.appService.getApplications(null, null, null, tags, null, PAGEABLE); Assert.assertEquals(3, apps.getNumberOfElements()); Assert.assertEquals(APP_3_ID, apps.getContent().get(0).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_2_ID, apps.getContent().get(1).getId().orElseThrow(IllegalArgumentException::new)); Assert.assertEquals(APP_1_ID, apps.getContent().get(2).getId().orElseThrow(IllegalArgumentException::new)); }
From source file:org.apache.hadoop.hbase.favored.FavoredNodeAssignmentHelper.java
private ServerName[] multiRackCaseWithRestrictions(Map<ServerName, Set<HRegionInfo>> serverToPrimaries, Map<HRegionInfo, ServerName[]> secondaryAndTertiaryMap, String primaryRack, ServerName primaryRS, HRegionInfo regionInfo) throws IOException { // Random to choose the secondary and tertiary region server // from another rack to place the secondary and tertiary // Random to choose one rack except for the current rack Set<String> rackSkipSet = new HashSet<String>(); rackSkipSet.add(primaryRack);//from ww w.j a v a 2 s . c o m String secondaryRack = getOneRandomRack(rackSkipSet); List<ServerName> serverList = getServersFromRack(secondaryRack); Set<ServerName> serverSet = new HashSet<ServerName>(); serverSet.addAll(serverList); ServerName[] favoredNodes; if (serverList.size() >= 2) { // Randomly pick up two servers from this secondary rack // Skip the secondary for the tertiary placement // skip the servers which share the primary already Set<HRegionInfo> primaries = serverToPrimaries.get(primaryRS); Set<ServerName> skipServerSet = new HashSet<ServerName>(); while (true) { ServerName[] secondaryAndTertiary = null; if (primaries.size() > 1) { // check where his tertiary and secondary are for (HRegionInfo primary : primaries) { secondaryAndTertiary = secondaryAndTertiaryMap.get(primary); if (secondaryAndTertiary != null) { if (getRackOfServer(secondaryAndTertiary[0]).equals(secondaryRack)) { skipServerSet.add(secondaryAndTertiary[0]); } if (getRackOfServer(secondaryAndTertiary[1]).equals(secondaryRack)) { skipServerSet.add(secondaryAndTertiary[1]); } } } } if (skipServerSet.size() + 2 <= serverSet.size()) break; skipServerSet.clear(); rackSkipSet.add(secondaryRack); // we used all racks if (rackSkipSet.size() == getTotalNumberOfRacks()) { // remove the last two added and break skipServerSet.remove(secondaryAndTertiary[0]); skipServerSet.remove(secondaryAndTertiary[1]); break; } secondaryRack = getOneRandomRack(rackSkipSet); serverList = getServersFromRack(secondaryRack); serverSet = new HashSet<ServerName>(); serverSet.addAll(serverList); } // Place the secondary RS ServerName secondaryRS = getOneRandomServer(secondaryRack, skipServerSet); skipServerSet.add(secondaryRS); // Place the tertiary RS ServerName tertiaryRS = getOneRandomServer(secondaryRack, skipServerSet); if (secondaryRS == null || tertiaryRS == null) { LOG.error("Cannot place the secondary and tertiary" + " region server for region " + regionInfo.getRegionNameAsString()); } // Create the secondary and tertiary pair favoredNodes = new ServerName[2]; favoredNodes[0] = secondaryRS; favoredNodes[1] = tertiaryRS; } else { // Pick the secondary rs from this secondary rack // and pick the tertiary from another random rack favoredNodes = new ServerName[2]; ServerName secondary = getOneRandomServer(secondaryRack); favoredNodes[0] = secondary; // Pick the tertiary if (getTotalNumberOfRacks() == 2) { // Pick the tertiary from the same rack of the primary RS Set<ServerName> serverSkipSet = new HashSet<ServerName>(); serverSkipSet.add(primaryRS); favoredNodes[1] = getOneRandomServer(primaryRack, serverSkipSet); } else { // Pick the tertiary from another rack rackSkipSet.add(secondaryRack); String tertiaryRandomRack = getOneRandomRack(rackSkipSet); favoredNodes[1] = getOneRandomServer(tertiaryRandomRack); } } return favoredNodes; }
From source file:org.apache.tez.dag.api.DAG.java
@Private @VisibleForTesting//w w w. j a va2s . c o m void checkAndInferOneToOneParallelism() { // infer all 1-1 via dependencies // collect all 1-1 edges where the source parallelism is set Set<Vertex> newKnownTasksVertices = Sets.newHashSet(); for (Vertex vertex : vertices.values()) { if (vertex.getParallelism() > -1) { newKnownTasksVertices.add(vertex); } } // walk through all known source 1-1 edges and infer parallelism // add newly inferred vertices for consideration as known sources // the outer loop will run for every new level of inferring the parallelism // however, the entire logic will process each vertex only once while (!newKnownTasksVertices.isEmpty()) { Set<Vertex> knownTasksVertices = Sets.newHashSet(newKnownTasksVertices); newKnownTasksVertices.clear(); for (Vertex v : knownTasksVertices) { for (Edge e : v.getOutputEdges()) { if (e.getEdgeProperty().getDataMovementType() == DataMovementType.ONE_TO_ONE) { Vertex outVertex = e.getOutputVertex(); if (outVertex.getParallelism() == -1) { LOG.info("Inferring parallelism for vertex: " + outVertex.getName() + " to be " + v.getParallelism() + " from 1-1 connection with vertex " + v.getName()); outVertex.setParallelism(v.getParallelism()); newKnownTasksVertices.add(outVertex); } } } } } // check for inconsistency and errors for (Edge e : edges) { Vertex inputVertex = e.getInputVertex(); Vertex outputVertex = e.getOutputVertex(); if (e.getEdgeProperty().getDataMovementType() == DataMovementType.ONE_TO_ONE) { if (inputVertex.getParallelism() != outputVertex.getParallelism()) { // both should be equal or equal to -1. if (outputVertex.getParallelism() != -1) { throw new TezUncheckedException( "1-1 Edge. Destination vertex parallelism must match source vertex. " + "Vertex: " + inputVertex.getName() + " does not match vertex: " + outputVertex.getName()); } } } } // check the vertices with -1 parallelism, currently only 3 cases are allowed to has -1 parallelism. // It is OK not using topological order to check vertices here. // 1. has input initializers // 2. 1-1 uninited sources // 3. has custom vertex manager for (Vertex vertex : vertices.values()) { if (vertex.getParallelism() == -1) { boolean hasInputInitializer = false; if (vertex.getDataSources() != null && !vertex.getDataSources().isEmpty()) { for (DataSourceDescriptor ds : vertex.getDataSources()) { if (ds.getInputInitializerDescriptor() != null) { hasInputInitializer = true; break; } } } if (hasInputInitializer) { continue; } else { // Account for the case where the vertex has a data source with a determined number of // shards e.g. splits calculated on the client and not in the AM // In this case, vertex parallelism is setup later using the data source's numShards // and as a result, an initializer is not needed. if (vertex.getDataSources() != null && vertex.getDataSources().size() == 1 && vertex.getDataSources().get(0).getNumberOfShards() > -1) { continue; } } boolean has1to1UninitedSources = false; if (vertex.getInputVertices() != null && !vertex.getInputVertices().isEmpty()) { for (Vertex srcVertex : vertex.getInputVertices()) { if (srcVertex.getParallelism() == -1) { has1to1UninitedSources = true; break; } } } if (has1to1UninitedSources) { continue; } if (vertex.getVertexManagerPlugin() != null) { continue; } throw new IllegalStateException( vertex.getName() + " has -1 tasks but does not have input initializers, " + "1-1 uninited sources or custom vertex manager to set it at runtime"); } } }
From source file:fr.landel.utils.assertor.AssertorIterableTest.java
/** * Test method for {@link AssertorIterable#contains}. * /*w w w.j a v a 2s.c o m*/ * @throws IOException * On not contain */ @Test public void testContains() throws IOException { final String el1 = "element1"; final String el2 = "element2"; final Set<String> set = new HashSet<>(); set.add(el1); Assertor.that(set).contains(el1).orElseThrow("iterable doesn't contain the element %s*"); Assertor.that(set, EnumAnalysisMode.STREAM).contains(el1) .orElseThrow("iterable doesn't contain the element %s*"); Assertor.that(set, EnumAnalysisMode.PARALLEL).contains(el1) .orElseThrow("iterable doesn't contain the element %s*"); assertException(() -> { Assertor.that(set).contains(el2).orElseThrow("iterable doesn't contain the element %2$s*"); fail(ERROR); }, IllegalArgumentException.class, "iterable doesn't contain the element " + el2); assertException(() -> { Assertor.that(set).contains(el2).orElseThrow(new IOException(), true); fail(ERROR); }, IOException.class); assertException(() -> { Assertor.that(set).contains((String) null).orElseThrow(); fail(ERROR); }, IllegalArgumentException.class, "the iterable '[element1]' should contain the object 'null'"); set.clear(); assertException(() -> { Assertor.that(set).contains(el1).orElseThrow(); fail(ERROR); }, IllegalArgumentException.class); assertException(() -> { Assertor.that(set).contains(el1).orElseThrow(); fail(ERROR); }, IllegalArgumentException.class, "the iterable cannot be null or empty"); assertException(() -> { Assertor.that((Iterable<String>) null).contains(el1).orElseThrow(); fail(ERROR); }, IllegalArgumentException.class, "the iterable cannot be null or empty"); assertException(() -> { Assertor.that(set).contains((String) null).orElseThrow(); fail(ERROR); }, IllegalArgumentException.class, "the iterable cannot be null or empty"); }
From source file:tools.xor.logic.DefaultUpdate4Set.java
public void testCase21() { // Initial association between A and C C = taskDao.findById(C.getId());/* w ww . j a v a 2 s . com*/ Set<Task> children = new HashSet<Task>(); children.add(C); // Setup the bi-directional link A = taskDao.findById(A.getId()); A.setTaskChildren(children); C.setTaskParent(A); taskDao.saveOrUpdate(A); // Initial association between D and B B = taskDao.findById(B.getId()); children = new HashSet<Task>(); children.add(B); // Setup the bi-directional link D = taskDao.findById(D.getId()); D.setTaskChildren(children); B.setTaskParent(D); taskDao.saveOrUpdate(D); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); D = (Task) aggregateService.read(D, getSettings()); C = A.getTaskChildren().iterator().next(); assert (C.getTaskParent() != null); // Remove child1 and add child2 children = A.getTaskChildren(); children.clear(); children.add(B); // D.getTaskChildren().clear(); should automatically clear the children by the framework B.setTaskParent(A); Settings settings = getSettings(); settings.setInterceptor(new Interceptor() { // check the number of actions in each object private void checkNumber(BusinessObject dataObject, List<Executable> actions) { Task task = (Task) dataObject.getInstance(); if (task.getName().equals(B_NAME)) { assert (actions.size() == 2); } else assert (actions.size() == 1); } @Override public void preBiDirActionStage(Map<PropertyKey, List<Executable>> actions) { // check the action queue to see if the correct number of actions are present assert (actions.size() == 4); for (Map.Entry<PropertyKey, List<Executable>> entry : actions.entrySet()) checkNumber(entry.getKey().getDataObject(), entry.getValue()); } }); A = (Task) aggregateService.update(A, settings); A = taskDao.findById(A.getId()); B = taskDao.findById(B.getId()); C = taskDao.findById(C.getId()); D = taskDao.findById(D.getId()); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); C = (Task) aggregateService.read(C, getSettings()); D = (Task) aggregateService.read(D, getSettings()); assert (A.getTaskChildren() != null && A.getTaskChildren().size() == 1); assert (B.getId() == A.getTaskChildren().iterator().next().getId()); assert (C.getTaskParent() == null); assert (D.getTaskChildren() == null || D.getTaskChildren().size() == 0); }
From source file:tools.xor.logic.DefaultUpdate4Set.java
public void testCase15() { // Initial association between A and C C = taskDao.findById(C.getId());//from w ww . j av a2 s. co m Set<Task> children = new HashSet<Task>(); children.add(C); // Setup the bi-directional link A = taskDao.findById(A.getId()); A.setTaskChildren(children); C.setTaskParent(A); taskDao.saveOrUpdate(A); // Initial association between D and B B = taskDao.findById(B.getId()); children = new HashSet<Task>(); children.add(B); // Setup the bi-directional link D = taskDao.findById(D.getId()); D.setTaskChildren(children); B.setTaskParent(D); taskDao.saveOrUpdate(D); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); D = (Task) aggregateService.read(D, getSettings()); C = A.getTaskChildren().iterator().next(); assert (C.getTaskParent() != null); // Remove child1 and add child2 children = A.getTaskChildren(); children.clear(); children.add(B); D.getTaskChildren().clear(); A.setAlternateTask(D); C.setTaskParent(null); B.setTaskParent(null); B.setAlternateTask(C); Settings settings = getSettings(); settings.setInterceptor(new Interceptor() { // check the number of actions in each object private void checkNumber(BusinessObject dataObject, List<Executable> actions) { Task task = (Task) dataObject.getInstance(); if (task.getName().equals(B_NAME)) { assert (actions.size() == 3); } else if (task.getName().equals(C_NAME)) { assert (actions.size() == 2); } else assert (actions.size() == 1); } @Override public void preBiDirActionStage(Map<PropertyKey, List<Executable>> actions) { // check the action queue to see if the correct number of actions are present assert (actions.size() == 4); for (Map.Entry<PropertyKey, List<Executable>> entry : actions.entrySet()) checkNumber(entry.getKey().getDataObject(), entry.getValue()); } }); A = (Task) aggregateService.update(A, settings); A = taskDao.findById(A.getId()); B = taskDao.findById(B.getId()); C = taskDao.findById(C.getId()); D = taskDao.findById(D.getId()); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); C = (Task) aggregateService.read(C, getSettings()); D = (Task) aggregateService.read(D, getSettings()); assert (A.getTaskChildren() != null && A.getTaskChildren().size() == 1); assert (B.getId() == A.getTaskChildren().iterator().next().getId()); assert (C.getTaskParent() == null); assert (D.getTaskChildren() == null || D.getTaskChildren().size() == 0); }
From source file:tools.xor.logic.DefaultUpdate4Set.java
public void testCase16() { // Initial association between A and C C = taskDao.findById(C.getId());/*from www . j av a 2 s . c o m*/ Set<Task> children = new HashSet<Task>(); children.add(C); // Setup the bi-directional link A = taskDao.findById(A.getId()); A.setTaskChildren(children); C.setTaskParent(A); taskDao.saveOrUpdate(A); // Initial association between D and B B = taskDao.findById(B.getId()); children = new HashSet<Task>(); children.add(B); // Setup the bi-directional link D = taskDao.findById(D.getId()); D.setTaskChildren(children); B.setTaskParent(D); taskDao.saveOrUpdate(D); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); D = (Task) aggregateService.read(D, getSettings()); C = A.getTaskChildren().iterator().next(); assert (C.getTaskParent() != null); // Remove child1 and add child2 children = A.getTaskChildren(); children.clear(); children.add(B); children = D.getTaskChildren(); children.clear(); children.add(C); A.setAlternateTask(D); C.setTaskParent(D); B.setTaskParent(A); B.setAlternateTask(C); Settings settings = getSettings(); settings.setInterceptor(new Interceptor() { // check the number of actions in each object private void checkNumber(BusinessObject dataObject, List<Executable> actions) { Task task = (Task) dataObject.getInstance(); if (task.getName().equals(B_NAME) || task.getName().equals(C_NAME)) { assert (actions.size() == 3); } else assert (actions.size() == 1); } @Override public void preBiDirActionStage(Map<PropertyKey, List<Executable>> actions) { // check the action queue to see if the correct number of actions are present assert (actions.size() == 4); for (Map.Entry<PropertyKey, List<Executable>> entry : actions.entrySet()) checkNumber(entry.getKey().getDataObject(), entry.getValue()); } }); A = (Task) aggregateService.update(A, settings); A = taskDao.findById(A.getId()); B = taskDao.findById(B.getId()); C = taskDao.findById(C.getId()); D = taskDao.findById(D.getId()); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); C = (Task) aggregateService.read(C, getSettings()); D = (Task) aggregateService.read(D, getSettings()); assert (A.getTaskChildren() != null && A.getTaskChildren().size() == 1); assert (B.getId() == A.getTaskChildren().iterator().next().getId()); assert (D.getTaskChildren() != null || D.getTaskChildren().size() == 1); assert (C.getId() == D.getTaskChildren().iterator().next().getId()); }
From source file:tools.xor.logic.DefaultUpdate4Set.java
public void testCase17() { // Initial association between A and C C = taskDao.findById(C.getId());// ww w . java 2s. co m Set<Task> children = new HashSet<Task>(); children.add(C); // Setup the bi-directional link A = taskDao.findById(A.getId()); A.setTaskChildren(children); C.setTaskParent(A); taskDao.saveOrUpdate(A); // Initial association between D and B B = taskDao.findById(B.getId()); children = new HashSet<Task>(); children.add(B); // Setup the bi-directional link D = taskDao.findById(D.getId()); D.setTaskChildren(children); B.setTaskParent(D); taskDao.saveOrUpdate(D); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); D = (Task) aggregateService.read(D, getSettings()); C = A.getTaskChildren().iterator().next(); assert (C.getTaskParent() != null); // Remove child1 and add child2 children = A.getTaskChildren(); children.clear(); children.add(B); children = D.getTaskChildren(); children.clear(); children.add(C); A.setAlternateTask(D); C.setTaskParent(D); B.setTaskParent(null); B.setAlternateTask(C); Settings settings = getSettings(); settings.setInterceptor(new Interceptor() { // check the number of actions in each object private void checkNumber(BusinessObject dataObject, List<Executable> actions) { Task task = (Task) dataObject.getInstance(); if (task.getName().equals(B_NAME) || task.getName().equals(C_NAME)) { assert (actions.size() == 3); } else assert (actions.size() == 1); } @Override public void preBiDirActionStage(Map<PropertyKey, List<Executable>> actions) { // check the action queue to see if the correct number of actions are present assert (actions.size() == 4); for (Map.Entry<PropertyKey, List<Executable>> entry : actions.entrySet()) checkNumber(entry.getKey().getDataObject(), entry.getValue()); } }); A = (Task) aggregateService.update(A, settings); A = taskDao.findById(A.getId()); B = taskDao.findById(B.getId()); C = taskDao.findById(C.getId()); D = taskDao.findById(D.getId()); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); C = (Task) aggregateService.read(C, getSettings()); D = (Task) aggregateService.read(D, getSettings()); assert (A.getTaskChildren() != null && A.getTaskChildren().size() == 1); assert (B.getId() == A.getTaskChildren().iterator().next().getId()); assert (D.getTaskChildren() != null || D.getTaskChildren().size() == 1); assert (C.getId() == D.getTaskChildren().iterator().next().getId()); }
From source file:tools.xor.logic.DefaultUpdate4Set.java
public void testCase18() { // Initial association between A and C C = taskDao.findById(C.getId());//from w ww .j a va2 s .c o m Set<Task> children = new HashSet<Task>(); children.add(C); // Setup the bi-directional link A = taskDao.findById(A.getId()); A.setTaskChildren(children); C.setTaskParent(A); taskDao.saveOrUpdate(A); // Initial association between D and B B = taskDao.findById(B.getId()); children = new HashSet<Task>(); children.add(B); // Setup the bi-directional link D = taskDao.findById(D.getId()); D.setTaskChildren(children); B.setTaskParent(D); taskDao.saveOrUpdate(D); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); D = (Task) aggregateService.read(D, getSettings()); C = A.getTaskChildren().iterator().next(); assert (C.getTaskParent() != null); // Remove child1 and add child2 children = A.getTaskChildren(); children.clear(); children.add(B); children = D.getTaskChildren(); children.clear(); //children.add(C); A.setAlternateTask(D); C.setTaskParent(D); B.setTaskParent(null); B.setAlternateTask(C); Settings settings = getSettings(); settings.setInterceptor(new Interceptor() { // check the number of actions in each object private void checkNumber(BusinessObject dataObject, List<Executable> actions) { Task task = (Task) dataObject.getInstance(); if (task.getName().equals(B_NAME)) { assert (actions.size() == 3); } else if (task.getName().equals(C_NAME)) { assert (actions.size() == 2); } else assert (actions.size() == 1); } @Override public void preBiDirActionStage(Map<PropertyKey, List<Executable>> actions) { // check the action queue to see if the correct number of actions are present assert (actions.size() == 4); for (Map.Entry<PropertyKey, List<Executable>> entry : actions.entrySet()) checkNumber(entry.getKey().getDataObject(), entry.getValue()); } }); A = (Task) aggregateService.update(A, settings); A = taskDao.findById(A.getId()); B = taskDao.findById(B.getId()); C = taskDao.findById(C.getId()); D = taskDao.findById(D.getId()); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); C = (Task) aggregateService.read(C, getSettings()); D = (Task) aggregateService.read(D, getSettings()); assert (A.getTaskChildren() != null && A.getTaskChildren().size() == 1); assert (B.getId() == A.getTaskChildren().iterator().next().getId()); assert (D.getTaskChildren() != null || D.getTaskChildren().size() == 1); assert (C.getId() == D.getTaskChildren().iterator().next().getId()); }
From source file:tools.xor.logic.DefaultUpdate4Set.java
public void testCase19() { // Initial association between A and C C = taskDao.findById(C.getId());//from w ww . j av a 2 s . c om Set<Task> children = new HashSet<Task>(); children.add(C); // Setup the bi-directional link A = taskDao.findById(A.getId()); A.setTaskChildren(children); C.setTaskParent(A); taskDao.saveOrUpdate(A); // Initial association between D and B B = taskDao.findById(B.getId()); children = new HashSet<Task>(); children.add(B); // Setup the bi-directional link D = taskDao.findById(D.getId()); D.setTaskChildren(children); B.setTaskParent(D); taskDao.saveOrUpdate(D); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); D = (Task) aggregateService.read(D, getSettings()); C = A.getTaskChildren().iterator().next(); assert (C.getTaskParent() != null); // Remove child1 and add child2 children = A.getTaskChildren(); children.clear(); children.add(B); children = D.getTaskChildren(); children.clear(); //children.add(C); A.setAlternateTask(D); C.setTaskParent(null); B.setTaskParent(null); B.setAlternateTask(C); Settings settings = getSettings(); settings.setInterceptor(new Interceptor() { // check the number of actions in each object private void checkNumber(BusinessObject dataObject, List<Executable> actions) { Task task = (Task) dataObject.getInstance(); if (task.getName().equals(B_NAME)) { assert (actions.size() == 3); } else if (task.getName().equals(C_NAME)) { assert (actions.size() == 2); } else assert (actions.size() == 1); } @Override public void preBiDirActionStage(Map<PropertyKey, List<Executable>> actions) { // check the action queue to see if the correct number of actions are present assert (actions.size() == 4); for (Map.Entry<PropertyKey, List<Executable>> entry : actions.entrySet()) checkNumber(entry.getKey().getDataObject(), entry.getValue()); } }); A = (Task) aggregateService.update(A, settings); A = taskDao.findById(A.getId()); B = taskDao.findById(B.getId()); C = taskDao.findById(C.getId()); D = taskDao.findById(D.getId()); A = (Task) aggregateService.read(A, getSettings()); B = (Task) aggregateService.read(B, getSettings()); C = (Task) aggregateService.read(C, getSettings()); D = (Task) aggregateService.read(D, getSettings()); assert (A.getTaskChildren() != null && A.getTaskChildren().size() == 1); assert (B.getId() == A.getTaskChildren().iterator().next().getId()); assert (D.getTaskChildren() == null || D.getTaskChildren().size() == 0); assert (C.getTaskParent() == null); }