@Override public IChemObject newTestObject() { return new AtomType("C"); } });
@Test public void testCompare_DiffAtomTypeName() { AtomType at1 = new AtomType("C"); AtomType at2 = new AtomType("C"); at1.setAtomTypeName(new String("C4")); at2.setAtomTypeName(new String("C3")); Assert.assertFalse(at1.compare(at2)); }
StringBuffer resultString = new StringBuffer(64); resultString.append("AtomType(").append(hashCode()); if (getAtomTypeName() != null) { resultString.append(", N:").append(getAtomTypeName()); if (getMaxBondOrder() != null) { resultString.append(", MBO:").append(getMaxBondOrder()); if (getBondOrderSum() != null) { resultString.append(", BOS:").append(getBondOrderSum()); if (getFormalCharge() != null) { resultString.append(", FC:").append(getFormalCharge()); if (getHybridization() != null) { resultString.append(", H:").append(getHybridization()); if (getFormalNeighbourCount() != null) { resultString.append(", NC:").append(getFormalNeighbourCount()); if (getCovalentRadius() != null) { resultString.append(", CR:").append(getCovalentRadius()); if (getValency() != null) { resultString.append(", EV:").append(getValency());
@Test public void testCompare_DiffBondOrderSum() { AtomType at1 = new AtomType("C"); AtomType at2 = new AtomType("C"); at1.setBondOrderSum(1.5); at2.setBondOrderSum(2.0); Assert.assertFalse(at1.compare(at2)); } }
/** * Compares a atom with this atom. * * @param object of type Atom * @return true, if the atoms are equal */ @Override public boolean compare(Object object) { if (!(object instanceof IAtom)) { return false; } if (!super.compare(object)) { return false; } Atom atom = (Atom) object; if (((point2d == atom.point2d) || ((point2d != null) && (point2d.equals(atom.point2d)))) && ((point3d == atom.point3d) || ((point3d != null) && (point3d.equals(atom.point3d)))) && (Objects.equals(hydrogenCount, atom.hydrogenCount)) && (Objects.equals(stereoParity, atom.stereoParity)) && (Objects.equals(charge, atom.charge))) { return true; } return false; }
/** * Compares a atom type with this atom type. * * @param object Object of type AtomType * @return true if the atom types are equal */ @Override public boolean compare(Object object) { if (!(object instanceof IAtomType)) { return false; } if (!super.compare(object)) { return false; } AtomType type = (AtomType) object; return Objects.equal(getAtomTypeName(), type.getAtomTypeName()) && Objects.equal(maxBondOrder, type.maxBondOrder) && Objects.equal(bondOrderSum, type.bondOrderSum); }
/** * Clones this atom object and its content. * * @return The cloned object */ @Override public IAtom clone() throws CloneNotSupportedException { Object clone = super.clone(); if (point2d != null) { ((Atom) clone).setPoint2d(new Point2d(point2d.x, point2d.y)); } if (point3d != null) { ((Atom) clone).setPoint3d(new Point3d(point3d.x, point3d.y, point3d.z)); } if (fractionalPoint3d != null) { ((Atom) clone).setFractionalPoint3d(new Point3d(fractionalPoint3d.x, fractionalPoint3d.y, fractionalPoint3d.z)); } return (IAtom) clone; }
@Test public void testCompare_BondOrderSum() { AtomType at1 = new AtomType("C"); AtomType at2 = new AtomType("C"); at1.setBondOrderSum(1.5); at2.setBondOrderSum(1.5); Assert.assertTrue(at1.compare(at2)); }
/** * Compares a atom with this atom. * * @param object of type Atom * @return true, if the atoms are equal */ @Override public boolean compare(Object object) { if (!(object instanceof IAtom)) { return false; } if (!super.compare(object)) { return false; } Atom atom = (Atom) object; if (((point2d == atom.point2d) || ((point2d != null) && (point2d.equals(atom.point2d)))) && ((point3d == atom.point3d) || ((point3d != null) && (point3d.equals(atom.point3d)))) && (Objects.equals(hydrogenCount, atom.hydrogenCount)) && (Objects.equals(stereoParity, atom.stereoParity)) && (Objects.equals(charge, atom.charge))) { return true; } return false; }
/** * Compares a atom type with this atom type. * * @param object Object of type AtomType * @return true if the atom types are equal */ @Override public boolean compare(Object object) { if (!(object instanceof IAtomType)) { return false; } if (!super.compare(object)) { return false; } AtomType type = (AtomType) object; return Objects.equal(getAtomTypeName(), type.getAtomTypeName()) && Objects.equal(maxBondOrder, type.maxBondOrder) && Objects.equal(bondOrderSum, type.bondOrderSum); }
/** * Clones this atom object and its content. * * @return The cloned object */ @Override public IAtom clone() throws CloneNotSupportedException { Object clone = super.clone(); if (point2d != null) { ((Atom) clone).setPoint2d(new Point2d(point2d.x, point2d.y)); } if (point3d != null) { ((Atom) clone).setPoint3d(new Point3d(point3d.x, point3d.y, point3d.z)); } if (fractionalPoint3d != null) { ((Atom) clone).setFractionalPoint3d(new Point3d(fractionalPoint3d.x, fractionalPoint3d.y, fractionalPoint3d.z)); } return (IAtom) clone; }
StringBuffer resultString = new StringBuffer(64); resultString.append("AtomType(").append(hashCode()); if (getAtomTypeName() != null) { resultString.append(", N:").append(getAtomTypeName()); if (getMaxBondOrder() != null) { resultString.append(", MBO:").append(getMaxBondOrder()); if (getBondOrderSum() != null) { resultString.append(", BOS:").append(getBondOrderSum()); if (getFormalCharge() != null) { resultString.append(", FC:").append(getFormalCharge()); if (getHybridization() != null) { resultString.append(", H:").append(getHybridization()); if (getFormalNeighbourCount() != null) { resultString.append(", NC:").append(getFormalNeighbourCount()); if (getCovalentRadius() != null) { resultString.append(", CR:").append(getCovalentRadius()); if (getValency() != null) { resultString.append(", EV:").append(getValency());
@BeforeClass public static void setUp() { setTestObjectBuilder(new ITestObjectBuilder() { @Override public IChemObject newTestObject() { return new AtomType("C"); } }); }
@Test public void testCompare_AtomTypeName() { AtomType at1 = new AtomType("C"); AtomType at2 = new AtomType("C"); at1.setAtomTypeName(new String("C4")); at2.setAtomTypeName(new String("C4")); Assert.assertTrue(at1.compare(at2)); }
@Test public void testAtomType_String() { IAtomType at = new AtomType("C"); Assert.assertEquals("C", at.getSymbol()); }
@Test public void unknownAtomTypeDoesNotModifyProperties() { IAtom atom = new Atom(Elements.CARBON); IAtomType atomType = new AtomType(Elements.Unknown.toIElement()); atomType.setAtomTypeName("X"); AtomTypeManipulator.configure(atom, atomType); assertThat(atom.getSymbol(), is("C")); assertThat(atom.getAtomicNumber(), is(6)); }
/** * @cdk.bug 1322 */ @Test public void aromaticityIsNotOverwritten() { IAtom atom = new Atom(Elements.CARBON); atom.setFlag(CDKConstants.ISAROMATIC, true); IAtomType atomType = new AtomType(Elements.Unknown.toIElement()); atomType.setFlag(CDKConstants.ISAROMATIC, false); atomType.setAtomTypeName("C.sp3"); AtomTypeManipulator.configure(atom, atomType); assertThat(atom.getFlag(CDKConstants.ISAROMATIC), is(true)); }
@Test public void testAtomType_String_String() { IAtomType at = new AtomType("C4", "C"); Assert.assertEquals("C", at.getSymbol()); Assert.assertEquals("C4", at.getAtomTypeName()); }
/** * @cdk.bug 1322 */ @Test public void aromaticitySetIfForType() { IAtom atom = new Atom(Elements.CARBON); atom.setFlag(CDKConstants.ISAROMATIC, false); IAtomType atomType = new AtomType(Elements.Unknown.toIElement()); atomType.setFlag(CDKConstants.ISAROMATIC, true); atomType.setAtomTypeName("C.am"); AtomTypeManipulator.configure(atom, atomType); assertThat(atom.getFlag(CDKConstants.ISAROMATIC), is(true)); } }
@Test public void testConfigureUnsetProperties() { IAtom atom = new Atom(Elements.CARBON); IAtomType atomType = new AtomType(Elements.CARBON); atomType.setExactMass(12.0); AtomTypeManipulator.configureUnsetProperties(atom, atomType); Assert.assertEquals(12.0, atom.getExactMass(), 0.1); }