- ssm.addMapping(acf1);
- ssm.addMapping(acf2);
- ssm.addMapping(acf1);
- ssm.removeMapping(acf1);
- assertEquals(2, ssm.seqmappings.size());
- assertTrue(ssm.seqmappings.contains(acf1));
- assertTrue(ssm.seqmappings.contains(acf2));
- assertEquals(1, ssm.getMappingReferenceCount(acf1));
- assertEquals(1, ssm.getMappingReferenceCount(acf2));
-
- /*
- * Remove both once more to clear the set.
- */
- ssm.removeMapping(acf1);
- ssm.removeMapping(acf2);
- assertEquals(0, ssm.seqmappings.size());
- assertEquals(0, ssm.getMappingReferenceCount(acf1));
- assertEquals(0, ssm.getMappingReferenceCount(acf2));
- }
-
- @Test(groups ={ "Functional" })
- public void testRemoveMappings()
- {
- AlignedCodonFrame acf1 = new AlignedCodonFrame();
- AlignedCodonFrame acf2 = new AlignedCodonFrame();
- AlignedCodonFrame acf3 = new AlignedCodonFrame();
-
- /*
- * Initial ref counts are 3/2/1:
- */
- ssm.addMapping(acf1);
- ssm.addMapping(acf1);
- ssm.addMapping(acf1);
- ssm.addMapping(acf2);
- ssm.addMapping(acf2);
- ssm.addMapping(acf3);
-
- Set<AlignedCodonFrame> set1 = new HashSet<AlignedCodonFrame>();
- set1.add(acf1);
- set1.add(acf2);
- Set<AlignedCodonFrame> set2 = new HashSet<AlignedCodonFrame>();
- set2.add(acf2);
- set2.add(acf3);
-
- /*
- * Remove one ref each to acf1, acf2, counts are now 2/1/1:
- */
- ssm.removeMappings(set1);
- assertEquals(3, ssm.seqmappings.size());
- assertTrue(ssm.seqmappings.contains(acf1));
- assertTrue(ssm.seqmappings.contains(acf2));
- assertTrue(ssm.seqmappings.contains(acf3));
- assertEquals(2, ssm.getMappingReferenceCount(acf1));
- assertEquals(1, ssm.getMappingReferenceCount(acf2));
- assertEquals(1, ssm.getMappingReferenceCount(acf3));
-
- /*
- * Remove one ref each to acf2, acf3 - they are removed
- */
- ssm.removeMappings(set2);
- assertEquals(1, ssm.seqmappings.size());
- assertTrue(ssm.seqmappings.contains(acf1));
- assertEquals(2, ssm.getMappingReferenceCount(acf1));