Search in sources :

Example 96 with IChemModel

use of org.openscience.cdk.interfaces.IChemModel in project cdk by cdk.

the class AbstractChemModelTest method testStateChanged_EventPropagation_Crystal.

@Test
public void testStateChanged_EventPropagation_Crystal() {
    ChemObjectListenerImpl listener = new ChemObjectListenerImpl();
    IChemModel chemObject = (IChemModel) newChemObject();
    chemObject.addListener(listener);
    ICrystal crystal = chemObject.getBuilder().newInstance(ICrystal.class);
    chemObject.setCrystal(crystal);
    Assert.assertTrue(listener.changed);
    // reset the listener
    listener.reset();
    Assert.assertFalse(listener.changed);
    // changing the set should trigger a change event in the IChemModel
    crystal.add(chemObject.getBuilder().newInstance(IAtomContainer.class));
    Assert.assertTrue(listener.changed);
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IChemModel(org.openscience.cdk.interfaces.IChemModel) Test(org.junit.Test)

Example 97 with IChemModel

use of org.openscience.cdk.interfaces.IChemModel in project cdk by cdk.

the class AbstractChemModelTest method testIsEmpty_Crystal.

@Test
public void testIsEmpty_Crystal() {
    IChemModel model = (IChemModel) newChemObject();
    IChemObjectBuilder builder = model.getBuilder();
    ICrystal crystal = builder.newInstance(ICrystal.class);
    model.setCrystal(crystal);
    Assert.assertTrue(model.isEmpty());
    crystal.addAtom(builder.newInstance(IAtom.class, "C"));
    Assert.assertFalse(model.isEmpty());
    model.setCrystal(null);
    Assert.assertTrue(model.isEmpty());
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) IChemModel(org.openscience.cdk.interfaces.IChemModel) IChemObjectBuilder(org.openscience.cdk.interfaces.IChemObjectBuilder) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 98 with IChemModel

use of org.openscience.cdk.interfaces.IChemModel in project cdk by cdk.

the class AbstractChemModelTest method testIsEmpty_RingSet.

@Test
public void testIsEmpty_RingSet() {
    IChemModel model = (IChemModel) newChemObject();
    IChemObjectBuilder builder = model.getBuilder();
    IAtomContainer container = builder.newInstance(IAtomContainer.class);
    IRingSet ringset = builder.newInstance(IRingSet.class);
    Assert.assertTrue(model.isEmpty());
    model.setRingSet(ringset);
    Assert.assertTrue(model.isEmpty());
    ringset.addAtomContainer(container);
    Assert.assertFalse(model.isEmpty());
    model.setRingSet(null);
    Assert.assertTrue(model.isEmpty());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IRingSet(org.openscience.cdk.interfaces.IRingSet) IChemModel(org.openscience.cdk.interfaces.IChemModel) IChemObjectBuilder(org.openscience.cdk.interfaces.IChemObjectBuilder) Test(org.junit.Test)

Example 99 with IChemModel

use of org.openscience.cdk.interfaces.IChemModel in project cdk by cdk.

the class AbstractChemModelTest method testSetMoleculeSet_IAtomContainerSet.

@Test
public void testSetMoleculeSet_IAtomContainerSet() {
    IChemModel chemModel = (IChemModel) newChemObject();
    IAtomContainerSet crystal = chemModel.getBuilder().newInstance(IAtomContainerSet.class);
    chemModel.setMoleculeSet(crystal);
    Assert.assertEquals(crystal, chemModel.getMoleculeSet());
}
Also used : IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IChemModel(org.openscience.cdk.interfaces.IChemModel) Test(org.junit.Test)

Example 100 with IChemModel

use of org.openscience.cdk.interfaces.IChemModel in project cdk by cdk.

the class AbstractChemSequenceTest method testGetChemModel_int.

@Test
public void testGetChemModel_int() {
    IChemSequence cs = (IChemSequence) newChemObject();
    cs.addChemModel(cs.getBuilder().newInstance(IChemModel.class));
    IChemModel second = cs.getBuilder().newInstance(IChemModel.class);
    cs.addChemModel(second);
    cs.addChemModel(cs.getBuilder().newInstance(IChemModel.class));
    Assert.assertEquals(second, cs.getChemModel(1));
}
Also used : IChemModel(org.openscience.cdk.interfaces.IChemModel) IChemSequence(org.openscience.cdk.interfaces.IChemSequence) Test(org.junit.Test)

Aggregations

IChemModel (org.openscience.cdk.interfaces.IChemModel)138 Test (org.junit.Test)97 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)85 IChemSequence (org.openscience.cdk.interfaces.IChemSequence)80 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)53 IChemFile (org.openscience.cdk.interfaces.IChemFile)50 InputStream (java.io.InputStream)46 ChemFile (org.openscience.cdk.ChemFile)30 CMLReader (org.openscience.cdk.io.CMLReader)26 IAtom (org.openscience.cdk.interfaces.IAtom)24 ICrystal (org.openscience.cdk.interfaces.ICrystal)21 IOException (java.io.IOException)19 IRingSet (org.openscience.cdk.interfaces.IRingSet)18 CDKException (org.openscience.cdk.exception.CDKException)17 IReaction (org.openscience.cdk.interfaces.IReaction)17 IReactionSet (org.openscience.cdk.interfaces.IReactionSet)17 MDLV2000Reader (org.openscience.cdk.io.MDLV2000Reader)13 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)12 AbstractChemModelTest (org.openscience.cdk.test.interfaces.AbstractChemModelTest)11 ChemObject (org.openscience.cdk.ChemObject)10