ReleasedPSFilter implements ProductStructureFilter, Serializable { @Override public List<PartIteration> filter(PartMaster part) { List<PartIteration> partIterations = new ArrayList<>(); List<PartRevision> partRevisions = part.getAllReleasedRevisions(); for(PartRevision partRevision: partRevisions){ partIterations.add(partRevision.getLastIteration()); } return partIterations; } ReleasedPSFilter(boolean diverge); @Override List<PartIteration> filter(PartMaster part); @Override List<PartLink> filter(List<PartLink> path);  }
@Test public void filterTestWithPartMasterAsParameter(){ List<PartIteration> result = releasedPSFilter.filter(getPartMasterWith("PART-001")); assertFalse(result.isEmpty()); assertEquals(6,result.size()); assertEquals("K",result.get(0).getPartVersion()); assertEquals("J",result.get(1).getPartVersion()); assertEquals("H",result.get(2).getPartVersion()); assertEquals("G",result.get(3).getPartVersion()); assertEquals("D",result.get(4).getPartVersion()); assertEquals("B", result.get(5).getPartVersion()); }
@Test public void filterTestWithListPartLinkAsParameterTest(){ PartMaster partMaster = getPartMasterWith("PART-001"); List<PartLink> links = new ArrayList<>((partMaster.getLastRevision().getLastIteration().getComponents())); List<PartLink> result = releasedPSFilter.filter(links); assertFalse(result.isEmpty()); assertEquals(1,result.size()); releasedPSFilter = new ReleasedPSFilter(true); result = releasedPSFilter.filter(links); assertFalse(result.isEmpty()); assertEquals(5,result.size()); assertEquals("PART-016-UsageLink",result.get(0).getReferenceDescription()); assertEquals("PART-018-Substitute",result.get(1).getReferenceDescription()); assertEquals("PART-015-Substitute",result.get(2).getReferenceDescription()); assertEquals("PART-009-Substitute",result.get(3).getReferenceDescription()); assertEquals("PART-012-Substitute",result.get(4).getReferenceDescription()); }