ProductBaselineCreationConfigSpec extends ProductConfigSpec { @Override public PartIteration filterPartIteration(PartMaster partMaster) { if (type.equals(ProductBaselineType.RELEASED)) { for (PartIteration pi : partIterations) { if (pi.getPartRevision().getPartMaster().getKey().equals(partMaster.getKey())) { retainedPartIterations.add(pi); return pi; } } PartRevision lastReleasedRevision = partMaster.getLastReleasedRevision(); if (lastReleasedRevision != null) { PartIteration pi = lastReleasedRevision.getLastIteration(); retainedPartIterations.add(pi); return pi; } } else if (type.equals(ProductBaselineType.LATEST)) { PartIteration pi = partMaster.getLastRevision().getLastCheckedInIteration(); if (pi != null) { retainedPartIterations.add(pi); return pi; } } return null; } ProductBaselineCreationConfigSpec(ProductBaselineType type, List<PartIteration> partIterations, List<String> substituteLinks, List<String> optionalUsageLinks); @Override PartIteration filterPartIteration(PartMaster partMaster); @Override PartLink filterPartLink(List<PartLink> path);  }
@Test public void filterPartIterationTest(){ PartIteration result = pB2CS.filterPartIteration(partMaster); assertNotNull(result); areThoseOfRevision("K", Collections.singletonList(result),partMaster.getNumber()); assertFalse(pB2CS.getRetainedPartIterations().isEmpty()); assertEquals(1,pB2CS.getRetainedPartIterations().size()); assertTrue(pB2CS.getRetainedPartIterations().contains(result)); partMaster = getPartMasterWith("PART-006"); result = pB2CS.filterPartIteration(partMaster); assertNull(result); addIterationTo( partMaster.getNumber(), partMaster.getLastRevision().createNextIteration(user)); partMaster.getLastRevision().setStatus(RevisionStatus.RELEASED); result = pB2CS.filterPartIteration(partMaster); assertNotNull(result); assertEquals(partMaster.getLastReleasedRevision().getLastIteration(),result); pB2CS = new ProductBaselineCreationConfigSpec(ProductBaselineType.LATEST, new ArrayList<>(), Collections.singletonList(""), Collections.singletonList("")); partMaster = getPartMasterWith("PART-005"); result = pB2CS.filterPartIteration(partMaster); assertNotNull(result); assertEquals(partMaster.getLastRevision().getLastCheckedInIteration(),result); }