@Test public void visit_should_return_last_effective_part_revision() throws EntityConstraintException, NotAllowedException, PartMasterNotFoundException { String workspaceId = "workspace01"; ConfigurationItem configurationItem = createConfigurationItem(workspaceId); ProductConfigSpec filter = new LotBasedEffectivityConfigSpec("50", configurationItem); User user = configurationItem.getAuthor(); Workspace workspace = configurationItem.getWorkspace(); PartMaster designItem = new PartMaster(workspace, "1", user); designItem.setPartRevisions(new ArrayList<PartRevision>() {{ add(createPartRevision(configurationItem, designItem, "1", "A", false, ProductBaselineType.EFFECTIVE_LOT_ID)); add(createPartRevision(configurationItem, designItem, "99", "D", false, ProductBaselineType.EFFECTIVE_LOT_ID)); }}); visit(workspaceId, filter, designItem); Assert.assertNotNull(filter); Assert.assertNotNull(filter.getRetainedPartIterations()); Assert.assertEquals(filter.getRetainedPartIterations().size(), 1); Assert.assertEquals(filter.getRetainedPartIterations() .stream() .filter(partIteration -> partIteration.getPartVersion().equals("D")) .count(), 1); ProductConfigSpec filter2 = new LotBasedEffectivityConfigSpec("50", configurationItem); PartMaster designItem2 = new PartMaster(workspace, "1", user); designItem2.setPartRevisions(new ArrayList<PartRevision>() {{ add(createPartRevision(configurationItem, designItem, "99", "D", false, ProductBaselineType.EFFECTIVE_LOT_ID)); add(createPartRevision(configurationItem, designItem, "1", "A", false, ProductBaselineType.EFFECTIVE_LOT_ID)); }}); visit(workspaceId, filter2, designItem2); Assert.assertNotNull(filter2); Assert.assertNotNull(filter2.getRetainedPartIterations()); Assert.assertEquals(filter2.getRetainedPartIterations().size(), 1); Assert.assertEquals(filter2.getRetainedPartIterations() .stream() .filter(partIteration -> partIteration.getPartVersion().equals("A")) .count(), 1); }
public Component visit(String workspaceId, ProductStructureFilter pFilter, PartMaster pNodeFrom, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks) throws PartMasterNotFoundException, EntityConstraintException, NotAllowedException { init(workspaceId, pStopAtDepth, pFilter, callbacks); return visit(pNodeFrom, new ArrayList<PartLink>() {{ add(createVirtualRootLink(pNodeFrom)); }}, new ArrayList<PartMaster>() {{ add(pNodeFrom); }} ); }
PSFilterVisitor { public Component visit(String workspaceId, ProductStructureFilter pFilter, PartMaster pNodeFrom, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks) throws PartMasterNotFoundException, EntityConstraintException, NotAllowedException { init(workspaceId, pStopAtDepth, pFilter, callbacks); return visit(pNodeFrom, new ArrayList<PartLink>() {{ add(createVirtualRootLink(pNodeFrom)); }}, new ArrayList<PartMaster>() {{ add(pNodeFrom); }} ); } }
PSFilterVisitor { public Component visit(String workspaceId, ProductStructureFilter pFilter, PartMaster pNodeFrom, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks) throws PartMasterNotFoundException, EntityConstraintException, NotAllowedException { init(workspaceId, pStopAtDepth, pFilter, callbacks); return visit(pNodeFrom, new ArrayList<PartLink>() {{ add(createVirtualRootLink(pNodeFrom)); }}, new ArrayList<PartMaster>() {{ add(pNodeFrom); }} ); }  }
PSFilterVisitor { public Component visit(String workspaceId, ProductStructureFilter pFilter, PartMaster pNodeFrom, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks) throws PartMasterNotFoundException, EntityConstraintException, NotAllowedException { init(workspaceId, pStopAtDepth, pFilter, callbacks); return visit(pNodeFrom, new ArrayList<PartLink>() {{ add(createVirtualRootLink(pNodeFrom)); }}, new ArrayList<PartMaster>() {{ add(pNodeFrom); }} ); }  Component visit(String workspaceId, ProductStructureFilter pFilter, PartMaster pNodeFrom, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks); Component visit(String workspaceId, ProductStructureFilter pFilter, List<PartLink> pStartingPath, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks); void stop(); }
PSFilterVisitor { public Component visit(String workspaceId, ProductStructureFilter pFilter, PartMaster pNodeFrom, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks) throws PartMasterNotFoundException, EntityConstraintException, NotAllowedException { init(workspaceId, pStopAtDepth, pFilter, callbacks); return visit(pNodeFrom, new ArrayList<PartLink>() {{ add(createVirtualRootLink(pNodeFrom)); }}, new ArrayList<PartMaster>() {{ add(pNodeFrom); }} ); }  Component visit(String workspaceId, ProductStructureFilter pFilter, PartMaster pNodeFrom, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks); Component visit(String workspaceId, ProductStructureFilter pFilter, List<PartLink> pStartingPath, Integer pStopAtDepth, PSFilterVisitorCallbacks callbacks); void stop();  }