BioPolymer extends Polymer implements java.io.Serializable, IBioPolymer { public BioPolymer() { super(); strands = new Hashtable<String, IStrand>(); } BioPolymer(); @Override void addAtom(IAtom oAtom, IStrand oStrand); @Override void addAtom(IAtom oAtom, IMonomer oMonomer, IStrand oStrand); @Override int getMonomerCount(); @Override IMonomer getMonomer(String monName, String strandName); @Override Collection<String> getMonomerNames(); @Override int getStrandCount(); @Override IStrand getStrand(String cName); @Override Collection<String> getStrandNames(); @Override void removeStrand(String name); @Override Map<String, IStrand> getStrands(); @Override String toString(); @Override IBioPolymer clone();  }
@Test public void testBioPolymer() { IBioPolymer oBioPolymer = new BioPolymer(); Assert.assertNotNull(oBioPolymer); Assert.assertEquals(oBioPolymer.getMonomerCount(), 0); IStrand oStrand1 = oBioPolymer.getBuilder().newInstance(IStrand.class); oStrand1.setStrandName("A"); IStrand oStrand2 = oBioPolymer.getBuilder().newInstance(IStrand.class); oStrand2.setStrandName("B"); IMonomer oMono1 = oBioPolymer.getBuilder().newInstance(IMonomer.class); oMono1.setMonomerName(new String("TRP279")); IMonomer oMono2 = oBioPolymer.getBuilder().newInstance(IMonomer.class); oMono2.setMonomerName(new String("HOH")); IMonomer oMono3 = oBioPolymer.getBuilder().newInstance(IMonomer.class); oMono3.setMonomerName(new String("GLYA16")); IAtom oAtom1 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C"); IAtom oAtom2 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C"); IAtom oAtom3 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C"); IAtom oAtom4 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C"); IAtom oAtom5 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C"); oBioPolymer.addAtom(oAtom1); oBioPolymer.addAtom(oAtom2, oStrand1); oBioPolymer.addAtom(oAtom3, oMono1, oStrand1); oBioPolymer.addAtom(oAtom4, oMono2, oStrand2); oBioPolymer.addAtom(oAtom5, oMono3, oStrand2); Assert.assertNotNull(oBioPolymer.getAtom(0)); Assert.assertNotNull(oBioPolymer.getAtom(1)); Assert.assertNotNull(oBioPolymer.getAtom(2)); Assert.assertNotNull(oBioPolymer.getAtom(3)); Assert.assertNotNull(oBioPolymer.getAtom(4)); Assert.assertEquals(oAtom1, oBioPolymer.getAtom(0)); Assert.assertEquals(oAtom2, oBioPolymer.getAtom(1)); Assert.assertEquals(oAtom3, oBioPolymer.getAtom(2)); Assert.assertEquals(oAtom4, oBioPolymer.getAtom(3)); Assert.assertEquals(oAtom5, oBioPolymer.getAtom(4)); Assert.assertNull(oBioPolymer.getMonomer("0815", "A")); Assert.assertNull(oBioPolymer.getMonomer("0815", "B")); Assert.assertNull(oBioPolymer.getMonomer("0815", "")); Assert.assertNull(oBioPolymer.getStrand("")); Assert.assertNotNull(oBioPolymer.getMonomer("TRP279", "A")); Assert.assertEquals(oMono1, oBioPolymer.getMonomer("TRP279", "A")); Assert.assertEquals(oBioPolymer.getMonomer("TRP279", "A").getAtomCount(), 1); Assert.assertNotNull(oBioPolymer.getMonomer("HOH", "B")); Assert.assertEquals(oMono2, oBioPolymer.getMonomer("HOH", "B")); Assert.assertEquals(oBioPolymer.getMonomer("HOH", "B").getAtomCount(), 1); Assert.assertEquals(oBioPolymer.getStrand("B").getAtomCount(), 2); Assert.assertEquals(oBioPolymer.getStrand("B").getMonomerCount(), 2); Assert.assertNull(oBioPolymer.getStrand("C")); Assert.assertNotNull(oBioPolymer.getStrand("B")); }