[Git][java-team/cmlxom][upstream] New upstream version 4.7
Andrius Merkys (@merkys)
gitlab at salsa.debian.org
Tue Dec 19 07:41:43 GMT 2023
Andrius Merkys pushed to branch upstream at Debian Java Maintainers / cmlxom
Commits:
1651839c by Andrius Merkys at 2023-12-19T01:58:26-05:00
New upstream version 4.7
- - - - -
20 changed files:
- CITATION.cff
- README.md
- pom.xml
- src/main/java/org/xmlcml/cml/base/CMLElement.java
- src/main/java/org/xmlcml/cml/base/CMLUtil.java
- src/main/java/org/xmlcml/molutil/ChemicalElement.java
- src/main/java/org/xmlcml/molutil/Molutils.java
- + src/test/java/org/xmlcml/cml/element/main/CMLAbundanceTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLActionListTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLActionTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLAtomTypeListTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLAtomTypeTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLBandListTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLBandTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLDictionaryTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLGradientTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLIdentifierTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLIsotopeTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLXaxisTest.java
- + src/test/java/org/xmlcml/cml/element/main/CMLYaxisTest.java
Changes:
=====================================
CITATION.cff
=====================================
@@ -1,8 +1,8 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: CMLXOM
-version: 4.6
-date-released: 2023-08-26
+version: 4.7
+date-released: 2023-12-18
url: "https://github.com/BlueObelisk/cmlxom"
preferred-citation:
type: article
=====================================
README.md
=====================================
@@ -12,7 +12,7 @@ implementing the XML object model (XOM) for the Chemical Markup Language (CML).
Instructions to increase the version:
```shell
-mvn versions:set -DnewVersion=4.7-SNAPSHOT
+mvn versions:set -DnewVersion=4.8-SNAPSHOT
```
Deploy to Sonatype with the following commands, for snapshots and releases respectively:
=====================================
pom.xml
=====================================
@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.blueobelisk</groupId>
<artifactId>cmlxom</artifactId>
- <version>4.6</version>
+ <version>4.7</version>
<packaging>jar</packaging>
<name>CMLXOM</name>
<description>A Java library for processing CML</description>
@@ -61,6 +61,10 @@
<id>glh29</id>
<name>Gemma Holliday</name>
</developer>
+ <developer>
+ <id>Gowrishankar04</id>
+ <name>Gowri Shankar K</name>
+ </developer>
<developer>
<id>iamramin</id>
<name>Ramin Ghorashi</name>
@@ -93,6 +97,10 @@
<id>karne</id>
<name>Michael Wright</name>
</developer>
+ <developer>
+ <id>lehebax</id>
+ <name>Sakshi Jain</name>
+ </developer>
<developer>
<id>msh41</id>
<name>Mark Holt</name>
@@ -125,6 +133,10 @@
<id>shk3</id>
<name>Stefan Kuhn</name>
</developer>
+ <developer>
+ <id>sivasuriyankumarasamy</id>
+ <name>sivasuriyankumarasamy</name>
+ </developer>
<developer>
<id>steinbeck</id>
<name>Christoph Steinbeck</name>
@@ -335,7 +347,7 @@
<dependency>
<groupId>org.blueobelisk</groupId>
<artifactId>euclid</artifactId>
- <version>2.6</version>
+ <version>2.7</version>
</dependency>
<dependency>
<groupId>xom</groupId>
@@ -362,12 +374,12 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>2.13.0</version>
+ <version>2.15.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
- <version>2.20.0</version>
+ <version>2.22.0</version>
</dependency>
<dependency>
<groupId>org.ccil.cowan.tagsoup</groupId>
=====================================
src/main/java/org/xmlcml/cml/base/CMLElement.java
=====================================
@@ -152,7 +152,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
* builder.
* Removes any Document parent
* Serializes the element and re-parses with CMLBuilder()
- * @param element
+ * @param element the Element to parse
* @return CMLElement (null if root element is not CML)
*/
public static CMLElement createCMLElement(Element element) {
@@ -171,7 +171,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
}
/**
* normally overridden
- * @param id
+ * @param id the identifier
*/
public void setId(String id) {
this.addAttribute(new Attribute(CMLXSD_ID, id));
@@ -189,7 +189,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
* copy constructor. copies attributes, children and properties using the
* copyFoo() routines (q.v.)
*
- * @param element
+ * @param element the element to copy
*/
public CMLElement(CMLElement element) {
this(element.getLocalName());
@@ -211,8 +211,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/**
* callback when constructing from XML. No-op unless overridden in subclass
*
- * @param parent
- * element
+ * @param parent element
*/
public void finishMakingElement(Element parent) {
}
@@ -266,8 +265,8 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
}
/** override replaceChild.
- * @param oldNode
- * @param newNode
+ * @param oldNode node to replace
+ * @param newNode node that replaces the old node
*/
public void replaceChild(Node oldNode, Node newNode) {
int pos = this.indexOf(oldNode);
@@ -281,8 +280,8 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/** override insertChild.
* if newNode has parent detach()es first
- * @param newNode
- * @param pos
+ * @param newNode new node to add
+ * @param pos position where to add the node
*/
public void insertChild(Node newNode, int pos) {
newNode.detach();
@@ -306,8 +305,8 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/** override addNamespaceDeclaration(prefix, uri) to make it immutable.
* if namespacePrefix is not set, set it, else returns no-op
* without message.
- * @param prefix
- * @param uri
+ * @param prefix prefix for the namespace
+ * @param uri URI of the namespace
*/
public void addNamespaceDeclaration(String prefix, String uri) {
String namespaceURI = this.getNamespaceURI(prefix);
@@ -319,7 +318,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/** override removeNamespaceDeclaration(prefix) to forbid it.
* @deprecated
*
- * @param prefix
+ * @param prefix prefix to remove
*/
public void removeNamespaceDeclaration(String prefix) {
String namespaceURI = this.getNamespaceURI(prefix);
@@ -330,7 +329,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/** override setLocalName(localName) to make it immutable.
* if localname is null sets it, else no-op
- * @param localName
+ * @param localName local name of this element
*/
public void setLocalName(String localName) {
String lName = this.getLocalName();
@@ -341,8 +340,8 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/** set attribute.
* reroutes special cases such as setId() => resetId()
- * @param attName
- * @param attValue
+ * @param attName name of the attribute
+ * @param attValue value of the attribute
*/
public void setAttribute(String attName, String attValue) {
// id is special
@@ -357,7 +356,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/** override setNamespaceURI(String namespaceURI) to make it immutable.
* if namespaceURI is not set, sets it, else no-op
- * @param namespaceURI
+ * @param namespaceURI URI of the namespace
*/
public void setNamespaceURI(String namespaceURI) {
String nURI = this.getNamespaceURI();
@@ -368,7 +367,7 @@ public class CMLElement extends Element implements CMLConstants, Comparable<CMLE
/** override setNamespacePrefix(String namespacePrefix) to make it immutable.
* if namespacePrefix is not set, sets it, else no-op
- * @param namespacePrefix
+ * @param namespacePrefix prefix of the namespace
*/
public void setNamespacePrefix(String namespacePrefix) {
String nPrefix = this.getNamespacePrefix();
=====================================
src/main/java/org/xmlcml/cml/base/CMLUtil.java
=====================================
@@ -1259,11 +1259,13 @@ public abstract class CMLUtil implements CMLConstants {
removeNonCMLAttributes(childElement);
}
}
- /**
-<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
- 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
- * @param s
- * @return
+ /** Removes the following content:
+ * <code>
+<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
+ 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
+ * </code>
+ * @param s String of the SVG document
+ * @return SVG document with problematic content removed
* @throws IOException
*/
public static Document stripDTDAndOtherProblematicXMLHeadings(String s) throws IOException {
=====================================
src/main/java/org/xmlcml/molutil/ChemicalElement.java
=====================================
@@ -232,11 +232,11 @@ public class ChemicalElement {
protected Color color;
/**
- * constructor.
+ * constructor of a new element
*
- * @param symbol
- * @param atomicNumber
- * @param atomicWeight
+ * @param symbol the symbol
+ * @param atomicNumber the atomic number
+ * @param atomicWeight the atomic weight
*/
public ChemicalElement(String symbol, int atomicNumber, double atomicWeight) {
this.atomicSymbol = symbol;
@@ -301,8 +301,8 @@ public class ChemicalElement {
}
/**
- * @param abundances
- * @param masses
+ * @param masses mass information of the isotopes
+ * @param abundances abundancy information of the isotopes
* @deprecated use setIsotopes.
*/
public void addIsotope(int[] masses, double[] abundances) {
@@ -312,8 +312,8 @@ public class ChemicalElement {
/**
* set isotopes.
*
- * @param masses
- * @param abundances
+ * @param masses mass information of the isotopes
+ * @param abundances abundancy information of the isotopes
*/
public void setIsotopes(int[] masses, double[] abundances) {
isotopeMasses = masses;
@@ -323,7 +323,7 @@ public class ChemicalElement {
/**
* set precise masses for the isotopes of this element
*
- * @param preciseMasses
+ * @param preciseMasses precise mass information of the isotopes
*/
public void setIsotopePreciseMasses(double [] preciseMasses) {
isotopePreciseMasses = preciseMasses;
@@ -371,7 +371,7 @@ public class ChemicalElement {
/**
* set covalent radius.
*
- * @param cov
+ * @param cov covalent radius of the element
*/
public void setCovalentRadius(double cov) {
covalentRadius = cov;
@@ -389,7 +389,7 @@ public class ChemicalElement {
/** get various types of radii
*
- * @param radiusType
+ * @param radiusType type of the radius to return the value of
* @return radius
*/
public double getRadius(RadiusType radiusType) {
@@ -428,7 +428,7 @@ public class ChemicalElement {
/**
* set atomic radius.
*
- * @param cov
+ * @param cov the atomic radius
*/
public void setAtomicRadius(double cov) {
atomicRadius = cov;
@@ -446,7 +446,7 @@ public class ChemicalElement {
/**
* set vdw radius.
*
- * @param vdw
+ * @param vdw the vanderwaals radius
*/
public void setVDWRadius(double vdw) {
vanderwaalsRadius = vdw;
@@ -465,7 +465,7 @@ public class ChemicalElement {
/**
* set electronegativity.
*
- * @param eneg
+ * @param eneg the new electronegativity of the element
*/
public void setElectronegativity(double eneg) {
electronegativity = eneg;
@@ -483,7 +483,7 @@ public class ChemicalElement {
/**
* set color
*
- * @param color
+ * @param color the new color of the element
*/
public void setColor(Color color) {
this.color = color;
@@ -683,7 +683,7 @@ public class ChemicalElement {
* get the element corresponding to a (case-insensitive) atomicSymbol; else
* returns null.
*
- * @param symbol case insensitive
+ * @param symbol the case insensitive symbol of the element to return
* @return element or null if not found
*/
public static ChemicalElement getChemicalElementIgnoreCase(String symbol) {
@@ -693,7 +693,7 @@ public class ChemicalElement {
/** get the element corresponding to a CASE-SENSITIVE atomicSymbol.
*
- * @param symbol
+ * @param symbol the case sensitive symbol of the element to return
* @return element or null if not found
*/
public static ChemicalElement getChemicalElement(String symbol) {
@@ -736,7 +736,7 @@ public class ChemicalElement {
/**
* get the element corresponding to atomic number; else returns null.
*
- * @param atomicNumber
+ * @param atomicNumber the atomic number of the element to return
* @return element
*/
public static ChemicalElement getElement(int atomicNumber) {
@@ -941,8 +941,7 @@ public class ChemicalElement {
/**
* Outputs details of element.
*
- * @param el
- * Element to output
+ * @param el element to output
*/
public static void debug(ChemicalElement el) {
@@ -981,7 +980,7 @@ public class ChemicalElement {
/**
* sets boding radius tolerance.
*
- * @param tol
+ * @param tol the tolerance
*/
public static void setBondingRadiusTolerance(double tol) {
bondingRadiusTolerance = (tol > 0.0) ? tol : bondingRadiusTolerance;
=====================================
src/main/java/org/xmlcml/molutil/Molutils.java
=====================================
@@ -103,7 +103,7 @@ public abstract class Molutils extends java.lang.Object implements CMLConstants
* @param length
* from aPoint
*
- * @throws EuclidRuntimeException
+ * @throws EuclidRuntimeException if the geometry parameter is invalid
* @return Point3[] ANY => 1, LINEAR => 2, TRIGONAL => 3, TETRAHEDRAL => 4
*/
public static List<Point3> calculate3DCoordinates0(Point3 aPoint,
@@ -163,7 +163,7 @@ public abstract class Molutils extends java.lang.Object implements CMLConstants
* @param angle
* B-A-X angle in radians
*
- * @throws EuclidRuntimeException
+ * @throws EuclidRuntimeException if the geometry is not LINEAR, TRIGONAL, or TETRAHEDRAL
* @return Point3d[] nwanted points (or zero if failed)
*/
public static List<Point3> calculate3DCoordinates1(Point3 aPoint,
@@ -239,7 +239,7 @@ public abstract class Molutils extends java.lang.Object implements CMLConstants
* @param angle
* B-A-X angle
*
- * @throws EuclidRuntimeException
+ * @throws EuclidRuntimeException if the geometry is not TRIGONAL or TETRAHEDRAL
* @return Point3d[] nwanted points (or zero if failed)
*/
public static List<Point3> calculate3DCoordinates2(Point3 aPoint,
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLAbundanceTest.java
=====================================
@@ -0,0 +1,408 @@
+/**
+ * Copyright 2023 Sakshi Jain
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import nu.xom.Element;
+import org.xmlcml.cml.base.CMLAttribute;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLAbundance;
+
+public class CMLAbundanceTest {
+ @Test
+ public void testCopy() {
+ CMLAbundance cml = new CMLAbundance();
+
+ Element cmlCopy = cml.copy();
+
+ assertEquals("Class should be CMLAbundance: ", CMLAbundance.class, cmlCopy.getClass());
+ }
+
+ @Test
+ public void testMakeElementInContext() {
+ CMLAbundance c = new CMLAbundance();
+
+ CMLElement actual = c.makeElementInContext(null);
+
+ assertEquals("Class should be CMLAbundance: ", CMLAbundance.class, actual.getClass());
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setTitle("testTitle");
+ CMLAttribute expected = new CMLAttribute("title");
+ expected.setCMLValue("testTitle");
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("Title attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setTitle("testTitle");
+ String expected = "testTitle";
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be 'testTitle': ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ String expected = null;
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setId("testId");
+ CMLAttribute expected = new CMLAttribute("id");
+ expected.setCMLValue("testId");
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("Id attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setId("testId");
+ String expected = "testId";
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be 'testId': ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ String expected = null;
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setConvention("testConvention");
+ CMLAttribute expected = new CMLAttribute("convention");
+ expected.setCMLValue("testConvention");
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("Convention attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setConvention("testConvention");
+ String expected = "testConvention";
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be 'testConvention': ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ String expected = null;
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setDictRef("test:dictRef");
+ CMLAttribute expected = new CMLAttribute("dictRef");
+ expected.setCMLValue("test:dictRef");
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("dictRef attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setDictRef("test:dictRef");
+ String expected = "test:dictRef";
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be 'test:dictRef': ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ String expected = null;
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetMinAttributeWhenMinIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setMin("0");
+ CMLAttribute expected = new CMLAttribute("min");
+ expected.setCMLValue("0");
+
+ CMLAttribute actual = cml.getMinAttribute();
+
+ assertEquals("LocalName should be 'min': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be '0': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetMinAttributeWhenMinIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("Min attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetMinWhenMinIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setMin("0");
+ String expected = "0";
+
+ String actual = cml.getMin();
+
+ assertEquals("Min value should be '0': ", expected, actual);
+ }
+
+ @Test
+ public void testGetMinWhenMinIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ String expected = null;
+
+ String actual = cml.getMin();
+
+ assertEquals("min value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetMaxAttributeWhenMaxIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setMax("0");
+ CMLAttribute expected = new CMLAttribute("max");
+ expected.setCMLValue("0");
+
+ CMLAttribute actual = cml.getMaxAttribute();
+
+ assertEquals("LocalName should be 'max': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be '0': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetMaxAttributeWhenMaxIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("Max attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetMaxWhenMaxIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setMax("0");
+ String expected = "0";
+
+ String actual = cml.getMax();
+
+ assertEquals("Max value should be '0': ", expected, actual);
+ }
+
+ @Test
+ public void testGetMaxWhenMaxIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ String expected = null;
+
+ String actual = cml.getMax();
+
+ assertEquals("max value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsAttributeWhenUnitsIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setUnits("units:ang");
+ CMLAttribute expected = new CMLAttribute("units");
+ expected.setCMLValue("units:ang");
+
+ CMLAttribute actual = cml.getUnitsAttribute();
+
+ assertEquals("LocalName should be 'units': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'units:ang': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetUnitsAttributeWhenUnitsIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getUnitsAttribute();
+
+ assertEquals("Units attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsWhenUnitsIsSet() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setUnits("units:ang");
+ String expected = "units:ang";
+
+ String actual = cml.getUnits();
+
+ assertEquals("Units value should be 'units:ang': ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsWhenUnitsIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ String expected = null;
+
+ String actual = cml.getUnits();
+
+ assertEquals("units value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetXmlContentWhenXmlContentIsSetAsString() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setXMLContent("1");
+ Double expected = 1d;
+
+ Double actual = cml.getXMLContent();
+
+ assertEquals("XmlContent value should be '1': ", expected, actual);
+ }
+
+ @Test
+ public void testGetXmlContentWhenXmlContentIsSetAsDouble() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setXMLContent(1d);
+ Double expected = 1d;
+
+ Double actual = cml.getXMLContent();
+
+ assertEquals("XmlContent value should be '1': ", expected, actual);
+ }
+
+ @Test
+ public void testGetXmlContentWhenXmlContentIsNotSet() {
+ CMLAbundance cml = new CMLAbundance();
+ try {
+ cml.getXMLContent();
+ }
+ catch (Exception exception) {
+ assertEquals("Should throw null pointer exception: ",
+ java.lang.NullPointerException.class, exception.getClass());
+ }
+ }
+
+ @Test
+ public void testSetAttribute() {
+ CMLAbundance cml = new CMLAbundance();
+ cml.setAttribute("title", "testTitle");
+ cml.setAttribute("id", "testId");
+ cml.setAttribute("convention", "testConvention");
+ cml.setAttribute("dictRef", "test:dictRef");
+ cml.setAttribute("min", "0");
+ cml.setAttribute("max", "1");
+ cml.setAttribute("units", "units:ang");
+
+ assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle());
+ assertEquals("Id should be 'testId': ", "testId", cml.getId());
+ assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention());
+ assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef());
+ assertEquals("Min should be '0': ", "0", cml.getMin());
+ assertEquals("Max should be '1': ", "1", cml.getMax());
+ assertEquals("Units should be 'units:ang': ", "units:ang", cml.getUnits());
+ }
+
+}
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLActionListTest.java
=====================================
@@ -0,0 +1,650 @@
+/**
+ * Copyright 2023 Sakshi Jain
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLAttribute;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLActionList;
+
+import static org.junit.Assert.*;
+
+public class CMLActionListTest {
+ @Test
+ public void testCopy() {
+ CMLActionList cml = new CMLActionList();
+
+ Element cmlCopy = cml.copy();
+
+ assertEquals("Class should be CMLActionList: ", CMLActionList.class, cmlCopy.getClass());
+ }
+
+ @Test
+ public void testMakeElementInContext() {
+ CMLActionList cml = new CMLActionList();
+
+ CMLElement actual = cml.makeElementInContext(null);
+
+ assertEquals("Class should be CMLActionList: ", CMLActionList.class, actual.getClass());
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setTitle("testTitle");
+ CMLAttribute expected = new CMLAttribute("title");
+ expected.setCMLValue("testTitle");
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("Title attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setTitle("testTitle");
+ String expected = "testTitle";
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be 'testTitle': ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setId("testId");
+ CMLAttribute expected = new CMLAttribute("id");
+ expected.setCMLValue("testId");
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("Id attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setId("testId");
+ String expected = "testId";
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be 'testId': ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setConvention("testConvention");
+ CMLAttribute expected = new CMLAttribute("convention");
+ expected.setCMLValue("testConvention");
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("Convention attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setConvention("testConvention");
+ String expected = "testConvention";
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be 'testConvention': ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setDictRef("test:dictRef");
+ CMLAttribute expected = new CMLAttribute("dictRef");
+ expected.setCMLValue("test:dictRef");
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("dictRef attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setDictRef("test:dictRef");
+ String expected = "test:dictRef";
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be 'test:dictRef': ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsAttributeWhenUnitsIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setUnits("units:ang");
+ CMLAttribute expected = new CMLAttribute("units");
+ expected.setCMLValue("units:ang");
+
+ CMLAttribute actual = cml.getUnitsAttribute();
+
+ assertEquals("LocalName should be 'units': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'units:ang': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetUnitsAttributeWhenUnitsIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("Units attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsWhenUnitsIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setUnits("units:ang");
+ String expected = "units:ang";
+
+ String actual = cml.getUnits();
+
+ assertEquals("Units value should be 'units:ang': ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsWhenUnitsIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getUnits();
+
+ assertEquals("units value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartAttributeWhenStartIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setStart("xsd:double");
+ CMLAttribute expected = new CMLAttribute("start");
+ expected.setCMLValue("xsd:double");
+
+ CMLAttribute actual = cml.getStartAttribute();
+
+ assertEquals("LocalName should be 'start': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetStartAttributeWhenStartIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getStartAttribute();
+
+ assertEquals("Start attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartWhenStartIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setStart("xsd:double");
+ String expected = "xsd:double";
+
+ String actual = cml.getStart();
+
+ assertEquals("Start value should be 'xsd:double': ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartWhenStartIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getStart();
+
+ assertEquals("Start value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartConditionAttributeWhenStartConditionIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setStartCondition("test");
+ CMLAttribute expected = new CMLAttribute("startCondition");
+ expected.setCMLValue("test");
+
+ CMLAttribute actual = cml.getStartConditionAttribute();
+
+ assertEquals("LocalName should be 'startCondition': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetStartConditionAttributeWhenStartConditionIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getStartConditionAttribute();
+
+ assertEquals("Start condition attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartConditionWhenStartConditionIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setStartCondition("test");
+ String expected = "test";
+
+ String actual = cml.getStartCondition();
+
+ assertEquals("Start condition value should be 'test': ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartConditionWhenStartConditionIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getStartCondition();
+
+ assertEquals("Start condition value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndAttributeWhenEndIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setEnd("xsd:double");
+ CMLAttribute expected = new CMLAttribute("end");
+ expected.setCMLValue("xsd:double");
+
+ CMLAttribute actual = cml.getEndAttribute();
+
+ assertEquals("LocalName should be 'end': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetEndAttributeWhenEndIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getEndAttribute();
+
+ assertEquals("End attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndWhenEndIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setEnd("xsd:double");
+ String expected = "xsd:double";
+
+ String actual = cml.getEnd();
+
+ assertEquals("End value should be 'xsd:double': ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndWhenEndIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getEnd();
+
+ assertEquals("End value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndConditionAttributeWhenEndConditionIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setEndCondition("test");
+ CMLAttribute expected = new CMLAttribute("endCondition");
+ expected.setCMLValue("test");
+
+ CMLAttribute actual = cml.getEndConditionAttribute();
+
+ assertEquals("LocalName should be 'endCondition': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetEndConditionAttributeWhenEndConditionIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getEndConditionAttribute();
+
+ assertEquals("End condition attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndConditionWhenEndConditionIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setEndCondition("test");
+ String expected = "test";
+
+ String actual = cml.getEndCondition();
+
+ assertEquals("End condition value should be 'test': ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndConditionWhenEndConditionIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getEndCondition();
+
+ assertEquals("End condition value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDurationAttributeWhenDurationIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setDuration("testDuration");
+ CMLAttribute expected = new CMLAttribute("duration");
+ expected.setCMLValue("testDuration");
+
+ CMLAttribute actual = cml.getDurationAttribute();
+
+ assertEquals("LocalName should be 'duration': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testDuration': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetDurationAttributeWhenDurationIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDurationAttribute();
+
+ assertEquals("Duration attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDurationWhenDurationIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setDuration("testDuration");
+ String expected = "testDuration";
+
+ String actual = cml.getDuration();
+
+ assertEquals("Duration value should be 'testDuration': ", expected, actual);
+ }
+
+ @Test
+ public void testGetDurationWhenDurationIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getDuration();
+
+ assertEquals("Duration value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTypeAttributeWhenTypeIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setType("testType");
+ CMLAttribute expected = new CMLAttribute("type");
+ expected.setCMLValue("testType");
+
+ CMLAttribute actual = cml.getTypeAttribute();
+
+ assertEquals("LocalName should be 'type': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testType': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetTypeAttributeWhenTypeIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getTypeAttribute();
+
+ assertEquals("Type attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTypeWhenTypeIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setType("testType");
+ String expected = "testType";
+
+ String actual = cml.getType();
+
+ assertEquals("Type value should be 'testType': ", expected, actual);
+ }
+
+ @Test
+ public void testGetTypeWhenTypeIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getType();
+
+ assertEquals("Type value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetOrderAttributeWhenOrderIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setOrder("parallel");
+ CMLAttribute expected = new CMLAttribute("order");
+ expected.setCMLValue("parallel");
+
+ CMLAttribute actual = cml.getOrderAttribute();
+
+ assertEquals("LocalName should be 'order': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'parallel': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetOrderAttributeWhenOrderIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getOrderAttribute();
+
+ assertEquals("Order attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetOrderWhenOrderIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setOrder("parallel");
+ String expected = "parallel";
+
+ String actual = cml.getOrder();
+
+ assertEquals("Order value should be 'parallel': ", expected, actual);
+ }
+
+ @Test
+ public void testGetOrderWhenOrderIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ String expected = null;
+
+ String actual = cml.getOrder();
+
+ assertEquals("Order value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetCountAttributeWhenCountIsSet() {
+ CMLActionList cml = new CMLActionList();
+ cml.setCount("1.0");
+ CMLAttribute expected = new CMLAttribute("count");
+ expected.setCMLValue("1.0");
+
+ CMLAttribute actual = cml.getCountAttribute();
+
+ assertEquals("LocalName should be 'count': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be '1.0': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetCountAttributeWhenCountIsNotSet() {
+ CMLActionList cml = new CMLActionList();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getCountAttribute();
+
+ assertEquals("Count attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetCountWhenCountIsSetAsString() {
+ CMLActionList cml = new CMLActionList();
+ cml.setCount("1.0");
+ Double expected = 1D;
+
+ Double actual = cml.getCount();
+
+ assertEquals("Count value should be '1': ", expected, actual);
+ }
+
+ @Test
+ public void testGetCountWhenCountIsSetAsDouble() {
+ CMLActionList cml = new CMLActionList();
+ cml.setCount(1D);
+ Double expected = 1D;
+
+ Double actual = cml.getCount();
+
+ assertEquals("Count value should be '1': ", expected, actual);
+ }
+
+ @Test
+ public void testSetAttribute() {
+ CMLActionList cml = new CMLActionList();
+ cml.setAttribute("title", "testTitle");
+ cml.setAttribute("id", "testId");
+ cml.setAttribute("convention", "testConvention");
+ cml.setAttribute("dictRef", "test:dictRef");
+ cml.setAttribute("units", "units:ang");
+ cml.setAttribute("start", "xsd:double");
+ cml.setAttribute("startCondition", "test");
+ cml.setAttribute("duration", "testDuration");
+ cml.setAttribute("end", "xsd:double");
+ cml.setAttribute("endCondition", "test");
+ cml.setAttribute("type", "testType");
+ cml.setAttribute("order", "parallel");
+ cml.setAttribute("count", "1.0");
+
+ assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle());
+ assertEquals("Id should be 'testId': ", "testId", cml.getId());
+ assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention());
+ assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef());
+ assertEquals("Units should be 'units:ang': ", "units:ang", cml.getUnits());
+ assertEquals("Start value should be 'xsd:double': ", "xsd:double", cml.getStart());
+ assertEquals("Start condition value should be 'test': ", "test", cml.getStartCondition());
+ assertEquals("Duration value should be 'testDuration': ", "testDuration", cml.getDuration());
+ assertEquals("End value should be 'xsd:double': ", "xsd:double", cml.getEnd());
+ assertEquals("End condition value should be 'test': ", "test", cml.getEndCondition());
+ assertEquals("Type condition value should be 'testType': ", "testType", cml.getType());
+ assertEquals("Order condition value should be 'parallel': ", "parallel", cml.getOrder());
+ assertEquals("Count condition value should be '1.0': ", "1.0", String.valueOf(cml.getCount()));
+ }
+}
\ No newline at end of file
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLActionTest.java
=====================================
@@ -0,0 +1,696 @@
+/**
+ * Copyright 2023 Sakshi Jain
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLAttribute;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLAction;
+
+import static org.junit.Assert.*;
+
+public class CMLActionTest {
+ @Test
+ public void testCopy() {
+ CMLAction cml = new CMLAction();
+
+ Element cmlCopy = cml.copy();
+
+ assertEquals("Class should be CMLAction: ", CMLAction.class, cmlCopy.getClass());
+ }
+
+ @Test
+ public void testMakeElementInContext() {
+ CMLAction cml = new CMLAction();
+
+ CMLElement actual = cml.makeElementInContext(null);
+
+ assertEquals("Class should be CMLAction: ", CMLAction.class, actual.getClass());
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setTitle("testTitle");
+ CMLAttribute expected = new CMLAttribute("title");
+ expected.setCMLValue("testTitle");
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("Title attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setTitle("testTitle");
+ String expected = "testTitle";
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be 'testTitle': ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setId("testId");
+ CMLAttribute expected = new CMLAttribute("id");
+ expected.setCMLValue("testId");
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("Id attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setId("testId");
+ String expected = "testId";
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be 'testId': ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setConvention("testConvention");
+ CMLAttribute expected = new CMLAttribute("convention");
+ expected.setCMLValue("testConvention");
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("Convention attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setConvention("testConvention");
+ String expected = "testConvention";
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be 'testConvention': ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setDictRef("test:dictRef");
+ CMLAttribute expected = new CMLAttribute("dictRef");
+ expected.setCMLValue("test:dictRef");
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("dictRef attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setDictRef("test:dictRef");
+ String expected = "test:dictRef";
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be 'test:dictRef': ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsAttributeWhenUnitsIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setUnits("units:ang");
+ CMLAttribute expected = new CMLAttribute("units");
+ expected.setCMLValue("units:ang");
+
+ CMLAttribute actual = cml.getUnitsAttribute();
+
+ assertEquals("LocalName should be 'units': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'units:ang': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetUnitsAttributeWhenUnitsIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("Units attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsWhenUnitsIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setUnits("units:ang");
+ String expected = "units:ang";
+
+ String actual = cml.getUnits();
+
+ assertEquals("Units value should be 'units:ang': ", expected, actual);
+ }
+
+ @Test
+ public void testGetUnitsWhenUnitsIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getUnits();
+
+ assertEquals("units value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartAttributeWhenStartIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setStart("xsd:double");
+ CMLAttribute expected = new CMLAttribute("start");
+ expected.setCMLValue("xsd:double");
+
+ CMLAttribute actual = cml.getStartAttribute();
+
+ assertEquals("LocalName should be 'start': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetStartAttributeWhenStartIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getStartAttribute();
+
+ assertEquals("Start attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartWhenStartIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setStart("xsd:double");
+ String expected = "xsd:double";
+
+ String actual = cml.getStart();
+
+ assertEquals("Start value should be 'xsd:double': ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartWhenStartIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getStart();
+
+ assertEquals("Start value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartConditionAttributeWhenStartConditionIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setStartCondition("test");
+ CMLAttribute expected = new CMLAttribute("startCondition");
+ expected.setCMLValue("test");
+
+ CMLAttribute actual = cml.getStartConditionAttribute();
+
+ assertEquals("LocalName should be 'startCondition': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetStartConditionAttributeWhenStartConditionIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getStartConditionAttribute();
+
+ assertEquals("Start condition attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartConditionWhenStartConditionIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setStartCondition("test");
+ String expected = "test";
+
+ String actual = cml.getStartCondition();
+
+ assertEquals("Start condition value should be 'test': ", expected, actual);
+ }
+
+ @Test
+ public void testGetStartConditionWhenStartConditionIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getStartCondition();
+
+ assertEquals("Start condition value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndAttributeWhenEndIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setEnd("xsd:double");
+ CMLAttribute expected = new CMLAttribute("end");
+ expected.setCMLValue("xsd:double");
+
+ CMLAttribute actual = cml.getEndAttribute();
+
+ assertEquals("LocalName should be 'end': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'xsd:double': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetEndAttributeWhenEndIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getEndAttribute();
+
+ assertEquals("End attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndWhenEndIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setEnd("xsd:double");
+ String expected = "xsd:double";
+
+ String actual = cml.getEnd();
+
+ assertEquals("End value should be 'xsd:double': ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndWhenEndIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getEnd();
+
+ assertEquals("End value value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndConditionAttributeWhenEndConditionIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setEndCondition("test");
+ CMLAttribute expected = new CMLAttribute("endCondition");
+ expected.setCMLValue("test");
+
+ CMLAttribute actual = cml.getEndConditionAttribute();
+
+ assertEquals("LocalName should be 'endCondition': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetEndConditionAttributeWhenEndConditionIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getEndConditionAttribute();
+
+ assertEquals("End condition attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndConditionWhenEndConditionIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setEndCondition("test");
+ String expected = "test";
+
+ String actual = cml.getEndCondition();
+
+ assertEquals("End condition value should be 'test': ", expected, actual);
+ }
+
+ @Test
+ public void testGetEndConditionWhenEndConditionIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getEndCondition();
+
+ assertEquals("End condition value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDurationAttributeWhenDurationIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setDuration("testDuration");
+ CMLAttribute expected = new CMLAttribute("duration");
+ expected.setCMLValue("testDuration");
+
+ CMLAttribute actual = cml.getDurationAttribute();
+
+ assertEquals("LocalName should be 'duration': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testDuration': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetDurationAttributeWhenDurationIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDurationAttribute();
+
+ assertEquals("Duration attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDurationWhenDurationIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setDuration("testDuration");
+ String expected = "testDuration";
+
+ String actual = cml.getDuration();
+
+ assertEquals("Duration value should be 'testDuration': ", expected, actual);
+ }
+
+ @Test
+ public void testGetDurationWhenDurationIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getDuration();
+
+ assertEquals("Duration value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTypeAttributeWhenTypeIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setType("testType");
+ CMLAttribute expected = new CMLAttribute("type");
+ expected.setCMLValue("testType");
+
+ CMLAttribute actual = cml.getTypeAttribute();
+
+ assertEquals("LocalName should be 'type': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testType': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetTypeAttributeWhenTypeIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getTypeAttribute();
+
+ assertEquals("Type attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTypeWhenTypeIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setType("testType");
+ String expected = "testType";
+
+ String actual = cml.getType();
+
+ assertEquals("Type value should be 'testType': ", expected, actual);
+ }
+
+ @Test
+ public void testGetTypeWhenTypeIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getType();
+
+ assertEquals("Type value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetOrderAttributeWhenOrderIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setOrder("parallel");
+ CMLAttribute expected = new CMLAttribute("order");
+ expected.setCMLValue("parallel");
+
+ CMLAttribute actual = cml.getOrderAttribute();
+
+ assertEquals("LocalName should be 'order': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'parallel': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetOrderAttributeWhenOrderIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getOrderAttribute();
+
+ assertEquals("Order attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetOrderWhenOrderIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setOrder("parallel");
+ String expected = "parallel";
+
+ String actual = cml.getOrder();
+
+ assertEquals("Order value should be 'parallel': ", expected, actual);
+ }
+
+ @Test
+ public void testGetOrderWhenOrderIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getOrder();
+
+ assertEquals("Order value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetCountAttributeWhenCountIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setCount("1.0");
+ CMLAttribute expected = new CMLAttribute("count");
+ expected.setCMLValue("1.0");
+
+ CMLAttribute actual = cml.getCountAttribute();
+
+ assertEquals("LocalName should be 'count': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be '1.0': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetCountAttributeWhenCountIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getCountAttribute();
+
+ assertEquals("Count attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetCountWhenCountIsSetAsString() {
+ CMLAction cml = new CMLAction();
+ cml.setCount("1.0");
+ Double expected = 1D;
+
+ Double actual = cml.getCount();
+
+ assertEquals("Count value should be '1': ", expected, actual);
+ }
+
+ @Test
+ public void testGetCountWhenCountIsSetAsDouble() {
+ CMLAction cml = new CMLAction();
+ cml.setCount(1D);
+ Double expected = 1D;
+
+ Double actual = cml.getCount();
+
+ assertEquals("Count value should be '1': ", expected, actual);
+ }
+
+ @Test
+ public void testGetRefAttributeWhenRefIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setRef("testRef");
+ CMLAttribute expected = new CMLAttribute("ref");
+ expected.setCMLValue("testRef");
+
+ CMLAttribute actual = cml.getRefAttribute();
+
+ assertEquals("LocalName should be 'ref': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testRef': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetRefAttributeWhenRefIsNotSet() {
+ CMLAction cml = new CMLAction();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getRefAttribute();
+
+ assertEquals("Ref attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetRefWhenRefIsSet() {
+ CMLAction cml = new CMLAction();
+ cml.setRef("testRef");
+ String expected = "testRef";
+
+ String actual = cml.getRef();
+
+ assertEquals("Ref should be 'testRef': ", expected, actual);
+ }
+
+ @Test
+ public void testGetRefWhenRefIsNotSet() {
+ CMLAction cml = new CMLAction();
+ String expected = null;
+
+ String actual = cml.getRef();
+
+ assertEquals("Ref should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testSetAttribute() {
+ CMLAction cml = new CMLAction();
+ cml.setAttribute("title", "testTitle");
+ cml.setAttribute("id", "testId");
+ cml.setAttribute("convention", "testConvention");
+ cml.setAttribute("dictRef", "test:dictRef");
+ cml.setAttribute("units", "units:ang");
+ cml.setAttribute("start", "xsd:double");
+ cml.setAttribute("startCondition", "test");
+ cml.setAttribute("duration", "testDuration");
+ cml.setAttribute("end", "xsd:double");
+ cml.setAttribute("endCondition", "test");
+ cml.setAttribute("type", "testType");
+ cml.setAttribute("order", "parallel");
+ cml.setAttribute("count", "1.0");
+ cml.setAttribute("ref", "testRef");
+
+ assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle());
+ assertEquals("Id should be 'testId': ", "testId", cml.getId());
+ assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention());
+ assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef());
+ assertEquals("Units should be 'units:ang': ", "units:ang", cml.getUnits());
+ assertEquals("Start value should be 'xsd:double': ", "xsd:double", cml.getStart());
+ assertEquals("Start condition value should be 'test': ", "test", cml.getStartCondition());
+ assertEquals("Duration value should be 'testDuration': ", "testDuration", cml.getDuration());
+ assertEquals("End value should be 'xsd:double': ", "xsd:double", cml.getEnd());
+ assertEquals("End condition value should be 'test': ", "test", cml.getEndCondition());
+ assertEquals("Type condition value should be 'testType': ", "testType", cml.getType());
+ assertEquals("Order condition value should be 'parallel': ", "parallel", cml.getOrder());
+ assertEquals("Count condition value should be '1.0': ", "1.0", String.valueOf(cml.getCount()));
+ assertEquals("Ref condition value should be 'testRef': ", "testRef", cml.getRef());
+ }
+}
\ No newline at end of file
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLAtomTypeListTest.java
=====================================
@@ -0,0 +1,56 @@
+/* Copyright 2023 Gowri Shankar K
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLAtomTypeList;
+
+
+public class CMLAtomTypeListTest {
+
+ @Test
+ public void testCMLAtomTypeList() {
+ CMLAtomTypeList cmlAtomTypeList = new CMLAtomTypeList();
+ Assert.assertNotNull("constructor: ", cmlAtomTypeList);
+ cmlAtomTypeList.setAttribute("atom", "atomTypeList");
+ CMLAtomTypeList cmlAtomTypeList1 = new CMLAtomTypeList(cmlAtomTypeList);
+ Assert.assertEquals("CMLAtomTypeList attributeValue should be atomTypeList: ", cmlAtomTypeList.getAttributeValue("atom"),
+ cmlAtomTypeList1.getAttributeValue("atom"));
+ }
+
+ @Test
+ public void testCMLAtomTypeListCopy() {
+ CMLAtomTypeList cmlAtomTypeList = new CMLAtomTypeList();
+ cmlAtomTypeList.setAttribute("atom", "atomTypeList");
+ CMLAtomTypeList cmlAtomTypeList1 = new CMLAtomTypeList(cmlAtomTypeList);
+ Element copy = cmlAtomTypeList1.copy();
+ Assert.assertEquals("class should be CMLAtomTypeList: ", copy.getClass(),
+ CMLAtomTypeList.class);
+ }
+
+ @Test
+ public void testCMLAtomTypeListMakeElementInContext() {
+ Element current = new Element("cmLAtomTypeList");
+
+ CMLAtomTypeList factoryElement = new CMLAtomTypeList();
+ CMLElement newElement = factoryElement.makeElementInContext(current);
+ Assert.assertEquals("class should be CMLAtomTypeList: ", newElement.getClass(),
+ CMLAtomTypeList.class);
+
+ }
+}
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLAtomTypeTest.java
=====================================
@@ -0,0 +1,493 @@
+/**
+ * Copyright 2023 Sakshi Jain
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLAttribute;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.base.CMLElements;
+import org.xmlcml.cml.element.*;
+
+import static org.junit.Assert.*;
+
+public class CMLAtomTypeTest {
+ @Test
+ public void testCopy() {
+ CMLAtomType cml = new CMLAtomType();
+
+ Element cmlCopy = cml.copy();
+
+ assertEquals("Class should be CMLAtomType: ", CMLAtomType.class, cmlCopy.getClass());
+ }
+
+ @Test
+ public void testMakeElementInContext() {
+ CMLAtomType cml = new CMLAtomType();
+
+ CMLElement actual = cml.makeElementInContext(null);
+
+ assertEquals("Class should be CMLAtomType: ", CMLAtomType.class, actual.getClass());
+ }
+
+ @Test
+ public void testGetNameAttributeWhenNameIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setName("testName");
+ CMLAttribute expected = new CMLAttribute("name");
+ expected.setCMLValue("testName");
+
+ CMLAttribute actual = cml.getNameAttribute();
+
+ assertEquals("LocalName should be 'name': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testName': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetNameAttributeWhenNameIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getNameAttribute();
+
+ assertEquals("Name attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetNameWhenNameIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setName("testName");
+ String expected = "testName";
+
+ String actual = cml.getName();
+
+ assertEquals("Name should be 'testName': ", expected, actual);
+ }
+
+ @Test
+ public void testGetNameWhenNameIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ String expected = null;
+
+ String actual = cml.getName();
+
+ assertEquals("Name should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetRefAttributeWhenRefIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setRef("testRef");
+ CMLAttribute expected = new CMLAttribute("ref");
+ expected.setCMLValue("testRef");
+
+ CMLAttribute actual = cml.getRefAttribute();
+
+ assertEquals("LocalName should be 'ref': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testRef': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetRefAttributeWhenRefIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getRefAttribute();
+
+ assertEquals("Ref attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetRefWhenRefIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setRef("testRef");
+ String expected = "testRef";
+
+ String actual = cml.getRef();
+
+ assertEquals("Ref should be 'testRef': ", expected, actual);
+ }
+
+ @Test
+ public void testGetRefWhenRefIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ String expected = null;
+
+ String actual = cml.getRef();
+
+ assertEquals("Ref should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetAtomRefAttributeWhenAtomRefIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setAtomRef("testAtomRef");
+ CMLAttribute expected = new CMLAttribute("atomRef");
+ expected.setCMLValue("testAtomRef");
+
+ CMLAttribute actual = cml.getAtomRefAttribute();
+
+ assertEquals("LocalName should be 'atomRef': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testAtomRef': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetAtomRefAttributeWhenAtomRefIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getAtomRefAttribute();
+
+ assertEquals("AtomRef attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetAtomRefWhenAtomRefIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setAtomRef("testAtomRef");
+ String expected = "testAtomRef";
+
+ String actual = cml.getAtomRef();
+
+ assertEquals("AtomRef should be 'testAtomRef': ", expected, actual);
+ }
+
+ @Test
+ public void testGetAtomRefWhenAtomRefIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ String expected = null;
+
+ String actual = cml.getAtomRef();
+
+ assertEquals("AtomRef should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setTitle("testTitle");
+ CMLAttribute expected = new CMLAttribute("title");
+ expected.setCMLValue("testTitle");
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("LocalName should be 'title': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testTitle': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetTitleAttributeWhenTitleIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getTitleAttribute();
+
+ assertEquals("Title attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setTitle("testTitle");
+ String expected = "testTitle";
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be 'testTitle': ", expected, actual);
+ }
+
+ @Test
+ public void testGetTitleWhenTitleIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ String expected = null;
+
+ String actual = cml.getTitle();
+
+ assertEquals("Title should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setId("testId");
+ CMLAttribute expected = new CMLAttribute("id");
+ expected.setCMLValue("testId");
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("LocalName should be 'id': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testId': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetIdAttributeWhenIdIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getIdAttribute();
+
+ assertEquals("Id attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setId("testId");
+ String expected = "testId";
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be 'testId': ", expected, actual);
+ }
+
+ @Test
+ public void testGetIdWhenIdIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ String expected = null;
+
+ String actual = cml.getId();
+
+ assertEquals("Id value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setConvention("testConvention");
+ CMLAttribute expected = new CMLAttribute("convention");
+ expected.setCMLValue("testConvention");
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("LocalName should be 'convention': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'testConvention': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetConventionAttributeWhenConventionIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getConventionAttribute();
+
+ assertEquals("Convention attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setConvention("testConvention");
+ String expected = "testConvention";
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be 'testConvention': ", expected, actual);
+ }
+
+ @Test
+ public void testGetConventionWhenConventionIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ String expected = null;
+
+ String actual = cml.getConvention();
+
+ assertEquals("Convention value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setDictRef("test:dictRef");
+ CMLAttribute expected = new CMLAttribute("dictRef");
+ expected.setCMLValue("test:dictRef");
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("LocalName should be 'dictRef': ", expected.getLocalName(), actual.getLocalName());
+ assertEquals("Value should be 'test:dictRef': ", expected.getValue(), actual.getValue());
+ }
+
+ @Test
+ public void testGetDictRefAttributeWhenDictRefIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLAttribute expected = null;
+
+ CMLAttribute actual = cml.getDictRefAttribute();
+
+ assertEquals("dictRef attribute should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsSet() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setDictRef("test:dictRef");
+ String expected = "test:dictRef";
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be 'test:dictRef': ", expected, actual);
+ }
+
+ @Test
+ public void testGetDictRefWhenDictRefIsNotSet() {
+ CMLAtomType cml = new CMLAtomType();
+ String expected = null;
+
+ String actual = cml.getDictRef();
+
+ assertEquals("dictRef value should be null: ", expected, actual);
+ }
+
+ @Test
+ public void testAddMolecule() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.addMolecule(new CMLMolecule());
+ CMLElements<CMLMolecule> actual = cml.getMoleculeElements();
+
+ assertEquals("Molecules list size should be 1: ", 1, actual.size());
+ }
+
+ @Test
+ public void testGetMoleculeElementsWhenNoMoleculesAdded() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLElements<CMLMolecule> actual = cml.getMoleculeElements();
+
+ assertEquals("Molecules list size should be 0: ", 0, actual.size());
+ }
+
+ @Test
+ public void testAddAtom() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.addAtom(new CMLAtom());
+ CMLElements<CMLAtom> actual = cml.getAtomElements();
+
+ assertEquals("Atom list size should be 1: ", 1, actual.size());
+ }
+
+ @Test
+ public void testGetAtomElementsWhenNoAtomsAdded() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLElements<CMLAtom> actual = cml.getAtomElements();
+
+ assertEquals("Atom list size should be 0: ", 0, actual.size());
+ }
+
+ @Test
+ public void testAddLabel() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.addLabel(new CMLLabel());
+ CMLElements<CMLLabel> actual = cml.getLabelElements();
+
+ assertEquals("Label list size should be 1: ", 1, actual.size());
+ }
+
+ @Test
+ public void testGetLabelElementsWhenNoLabelsAdded() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLElements<CMLLabel> actual = cml.getLabelElements();
+
+ assertEquals("Label list size should be 0: ", 0, actual.size());
+ }
+
+ @Test
+ public void testAddScalar() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.addScalar(new CMLScalar());
+ CMLElements<CMLScalar> actual = cml.getScalarElements();
+
+ assertEquals("Scalars list size should be 1: ", 1, actual.size());
+ }
+
+ @Test
+ public void testGetScalarElementsWhenNoScalarsAdded() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLElements<CMLScalar> actual = cml.getScalarElements();
+
+ assertEquals("Scalars list size should be 0: ", 0, actual.size());
+ }
+
+ @Test
+ public void testAddArray() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.addArray(new CMLArray());
+ CMLElements<CMLArray> actual = cml.getArrayElements();
+
+ assertEquals("Arrays list size should be 1: ", 1, actual.size());
+ }
+
+ @Test
+ public void testGetArrayElementsWhenNoArraysAdded() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLElements<CMLArray> actual = cml.getArrayElements();
+
+ assertEquals("Arrays list size should be 0: ", 0, actual.size());
+ }
+
+ @Test
+ public void testAddMatrix() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.addMatrix(new CMLMatrix());
+ CMLElements<CMLMatrix> actual = cml.getMatrixElements();
+
+ assertEquals("Matrix list size should be 1: ", 1, actual.size());
+ }
+
+ @Test
+ public void testGetMatrixElementsWhenNoMatrixAdded() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLElements<CMLMatrix> actual = cml.getMatrixElements();
+
+ assertEquals("Matrix list size should be 0: ", 0, actual.size());
+ }
+
+ @Test
+ public void testAddProperty() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.addProperty(new CMLProperty());
+ CMLElements<CMLProperty> actual = cml.getPropertyElements();
+
+ assertEquals("Property list size should be 1: ", 1, actual.size());
+ }
+
+ @Test
+ public void testGetPropertyElementsWhenNoPropertyAdded() {
+ CMLAtomType cml = new CMLAtomType();
+ CMLElements<CMLProperty> actual = cml.getPropertyElements();
+
+ assertEquals("Property list size should be 0: ", 0, actual.size());
+ }
+
+ @Test
+ public void testSetAttribute() {
+ CMLAtomType cml = new CMLAtomType();
+ cml.setAttribute("name", "testName");
+ cml.setAttribute("title", "testTitle");
+ cml.setAttribute("id", "testId");
+ cml.setAttribute("convention", "testConvention");
+ cml.setAttribute("dictRef", "test:dictRef");
+ cml.setAttribute("ref", "testRef");
+ cml.setAttribute("atomRef", "testAtomRef");
+
+ assertEquals("Name should be 'testName': ", "testName", cml.getName());
+ assertEquals("Title should be 'testTitle': ", "testTitle", cml.getTitle());
+ assertEquals("Id should be 'testId': ", "testId", cml.getId());
+ assertEquals("Convention should be 'testConvention': ", "testConvention", cml.getConvention());
+ assertEquals("DictRef should be 'test:dictRef': ", "test:dictRef", cml.getDictRef());
+ assertEquals("Ref condition value should be 'testRef': ", "testRef", cml.getRef());
+ assertEquals("AtomRef condition value should be 'testAtomRef': ", "testAtomRef", cml.getAtomRef());
+ }
+}
\ No newline at end of file
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLBandListTest.java
=====================================
@@ -0,0 +1,56 @@
+/* Copyright 2023 Gowri Shankar K
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLBandList;
+
+public class CMLBandListTest {
+
+ @Test
+ public void testCMLBandList() {
+ CMLBandList cmlBandList = new CMLBandList();
+ Assert.assertNotNull("constructor: ", cmlBandList);
+ cmlBandList.setAttribute("band", "bandList");
+ CMLBandList cmlBandList1 = new CMLBandList(cmlBandList);
+ Assert.assertEquals("CMLBandList attributeValue should be bandList: ", cmlBandList.getAttributeValue("band"),
+ cmlBandList1.getAttributeValue("band"));
+ }
+
+ @Test
+ public void testCMLBandListCopy() {
+ CMLBandList cmlBandList = new CMLBandList();
+ cmlBandList.setAttribute("band", "bandList");
+ CMLBandList cmlBandList1 = new CMLBandList(cmlBandList);
+ Element copy = cmlBandList1.copy();
+ Assert.assertEquals("class should be CMLBandList: ", copy.getClass(),
+ CMLBandList.class);
+ }
+
+ @Test
+ public void testCMLBandListMakeElementInContext() {
+ Element current = new Element("cmlYaxis");
+
+ CMLBandList factoryElement = new CMLBandList();
+ CMLElement newElement = factoryElement.makeElementInContext(current);
+ Assert.assertEquals("class should be CMLBandList: ", newElement.getClass(),
+ CMLBandList.class);
+
+ }
+
+}
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLBandTest.java
=====================================
@@ -0,0 +1,56 @@
+/* Copyright 2023 Gowri Shankar K
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLBand;
+
+public class CMLBandTest {
+
+ @Test
+ public void testCMLBand() {
+ CMLBand cmlBand = new CMLBand();
+ Assert.assertNotNull("constructor: ", cmlBand);
+ cmlBand.setAttribute("band", "bandValue");
+ CMLBand cmlBand1 = new CMLBand(cmlBand);
+ Assert.assertEquals("CMLBand attributeValue should be bandValue: ", cmlBand.getAttributeValue("band"),
+ cmlBand1.getAttributeValue("band"));
+ }
+
+ @Test
+ public void testCMLBandCopy() {
+ CMLBand cmlBand = new CMLBand();
+ cmlBand.setAttribute("band", "BandValue");
+ CMLBand cmlBand1 = new CMLBand(cmlBand);
+ Element copy = cmlBand1.copy();
+ Assert.assertEquals("class should be CMLBand: ", copy.getClass(),
+ CMLBand.class);
+ }
+
+ @Test
+ public void testCMLBandMakeElementInContext() {
+ Element current = new Element("cmlYaxis");
+
+ CMLBand factoryElement = new CMLBand();
+ CMLElement newElement = factoryElement.makeElementInContext(current);
+ Assert.assertEquals("class should be CMLBand: ", newElement.getClass(),
+ CMLBand.class);
+
+ }
+
+}
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLDictionaryTest.java
=====================================
@@ -0,0 +1,114 @@
+/**
+ * Copyright 2023 Sivasuriyan
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.xmlcml.cml.element.CMLDictionary;
+import org.xmlcml.cml.element.CMLEntry;
+
+public class CMLDictionaryTest {
+
+ private CMLEntry cmlEntry1 = new CMLEntry("1");
+ private CMLEntry cmlEntry2 = new CMLEntry("2");
+
+ @Test
+ public void testRemoveEntryById() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ cmlDictionary.insertChild(cmlEntry1, 0);
+ cmlDictionary.insertChild(cmlEntry2, 1);
+
+ cmlDictionary.removeEntryById("1");
+
+ Assert.assertEquals(null, cmlDictionary.getCMLEntry("1"));
+ Assert.assertEquals("2", cmlDictionary.getCMLEntry("2").getId());
+ }
+
+ @Test
+ public void testRemoveEntry() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ cmlDictionary.insertChild(cmlEntry1, 0);
+ cmlDictionary.insertChild(cmlEntry2, 1);
+ CMLEntry entryToBeRemoved = cmlEntry1;
+
+ cmlDictionary.removeEntry(entryToBeRemoved);
+
+ Assert.assertEquals(null, cmlDictionary.getCMLEntry("1"));
+ Assert.assertEquals("2", cmlDictionary.getCMLEntry("2").getId());
+ }
+
+ @Test
+ public void testAddEntry() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ cmlDictionary.insertChild(cmlEntry1, 0);
+ CMLEntry entryToBeAdded = new CMLEntry("4");
+
+ cmlDictionary.addEntry(entryToBeAdded);
+
+ Assert.assertEquals("4", cmlDictionary.getCMLEntry("4").getId());
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testAddEntry_whenIdIsNull() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ CMLEntry entryToBeAdded = new CMLEntry();
+
+ cmlDictionary.addEntry(entryToBeAdded);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testAddEntry_whenIdIsAlreadyPresent() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ cmlDictionary.insertChild(cmlEntry1, 0);
+ cmlDictionary.insertChild(cmlEntry2, 1);
+ CMLEntry entryToBeAdded = cmlEntry1;
+
+ cmlDictionary.addEntry(entryToBeAdded);
+ }
+
+ @Test
+ public void testAddEntryInOrder() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ cmlDictionary.insertChild(cmlEntry1, 0);
+ cmlDictionary.insertChild(cmlEntry2, 1);
+ CMLEntry entryToBeAdded = new CMLEntry("0");
+
+ cmlDictionary.addEntryInOrder(entryToBeAdded);
+
+ Assert.assertEquals("0", cmlDictionary.getCMLEntry("0").getId());
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testAddEntryInOrder_whenIdIsNull() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ CMLEntry entryToBeAdded = new CMLEntry();
+
+ cmlDictionary.addEntryInOrder(entryToBeAdded);
+ }
+
+ @Test
+ public void testGetGenericEntry() {
+ CMLDictionary cmlDictionary = new CMLDictionary();
+ cmlDictionary.insertChild(cmlEntry1, 0);
+ cmlDictionary.insertChild(cmlEntry2, 1);
+
+ CMLEntry actual = cmlDictionary.getGenericEntry("1");
+
+ Assert.assertEquals(actual,cmlEntry1);
+ }
+}
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLGradientTest.java
=====================================
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2023 Sivasuriyan
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLGradient;
+
+public class CMLGradientTest {
+
+ CMLGradient cmlGradient;
+
+ @Before
+ public void setup(){
+ cmlGradient = new CMLGradient();
+ }
+
+ @Test
+ public void testCMLGradientCopy() {
+ Element copyElement = cmlGradient.copy();
+ Assert.assertEquals(copyElement.getClass(), CMLGradient.class);
+ }
+
+ @Test
+ public void testMakeElementInContext() {
+ Element element = new CMLGradient();
+ CMLElement actual = cmlGradient.makeElementInContext(element);
+ Assert.assertEquals(CMLGradient.class, actual.getClass());
+ }
+
+ @Test
+ public void testCMLGradient() {
+ CMLGradient cmlGradientOld = new CMLGradient();
+ CMLGradient cmlGradient = new CMLGradient(cmlGradientOld);
+ Assert.assertEquals(cmlGradient.getClass(), CMLGradient.class);
+ }
+}
\ No newline at end of file
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLIdentifierTest.java
=====================================
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2023 Sivasuriyan
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLGradient;
+import org.xmlcml.cml.element.CMLIdentifier;
+
+import static org.junit.Assert.*;
+
+public class CMLIdentifierTest {
+
+ CMLIdentifier cmlIdentifier;
+ @Before
+ public void setUp() {
+ cmlIdentifier = new CMLIdentifier();
+ }
+
+ @Test
+ public void testCMLIdentifierCopy() {
+ Element copyElement = cmlIdentifier.copy();
+ Assert.assertEquals(copyElement.getClass(), CMLIdentifier.class);
+ }
+
+ @Test
+ public void testMakeElementInContext() {
+ Element element = new CMLIdentifier();
+ CMLElement actual = cmlIdentifier.makeElementInContext(element);
+ Assert.assertEquals(CMLIdentifier.class, actual.getClass());
+ }
+
+ @Test
+ public void testCMLIdentifier() {
+ CMLIdentifier cmlIdentifierOld = new CMLIdentifier();
+ CMLIdentifier cmlIdentifier = new CMLIdentifier(cmlIdentifierOld);
+ Assert.assertEquals(cmlIdentifier.getClass(), CMLIdentifier.class);
+ }
+}
\ No newline at end of file
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLIsotopeTest.java
=====================================
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2023 Sivasuriyan
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLGradient;
+import org.xmlcml.cml.element.CMLIsotope;
+
+import static org.junit.Assert.*;
+
+public class CMLIsotopeTest {
+
+ CMLIsotope cmlIsotope;
+ @Before
+ public void setUp() {
+ cmlIsotope = new CMLIsotope();
+ }
+
+ @Test
+ public void testCMLIsotopeCopy() {
+ Element copyElement = cmlIsotope.copy();
+ Assert.assertEquals(copyElement.getClass(), CMLIsotope.class);
+ }
+
+ @Test
+ public void testMakeElementInContext() {
+ Element element = new CMLIsotope();
+ CMLElement actual = cmlIsotope.makeElementInContext(element);
+ Assert.assertEquals(CMLIsotope.class, actual.getClass());
+ }
+
+ @Test
+ public void testCMLIsotope() {
+ CMLIsotope cmlIsotopOld = new CMLIsotope();
+ CMLIsotope cmlIsotope = new CMLIsotope(cmlIsotopOld);
+ Assert.assertEquals(cmlIsotope.getClass(), CMLIsotope.class);
+ }
+}
\ No newline at end of file
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLXaxisTest.java
=====================================
@@ -0,0 +1,63 @@
+/* Copyright 2023 Gowri Shankar K
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLAxis;
+import org.xmlcml.cml.element.CMLXaxis;
+
+public class CMLXaxisTest {
+
+ @Test
+ public void testCMLXaxisList() {
+ CMLXaxis cmlXaxis = new CMLXaxis();
+ Assert.assertNotNull("constructor: ", cmlXaxis);
+ cmlXaxis.setAttribute("axis", "Xaxis");
+ CMLXaxis cmlXaxis1 = new CMLXaxis(cmlXaxis);
+ Assert.assertEquals("CMLXaxis attributeValue should be Xaxis: ", cmlXaxis.getAttributeValue("axis"),
+ cmlXaxis1.getAttributeValue("axis"));
+ }
+
+ @Test
+ public void testCMLXaxisCopy() {
+ CMLXaxis cmlXaxis = new CMLXaxis();
+ cmlXaxis.setAttribute("axis", "Xaxis");
+ CMLXaxis cmlXaxis1 = new CMLXaxis(cmlXaxis);
+ Element copy = cmlXaxis1.copy();
+ Assert.assertEquals("class should be CMLXaxis: ", copy.getClass(),
+ CMLXaxis.class);
+ }
+
+ @Test
+ public void testCMLXaxisMakeElementInContext() {
+ Element current = new Element("cmlXaxis");
+
+ CMLXaxis factoryElement = new CMLXaxis();
+ CMLElement newElement = factoryElement.makeElementInContext(current);
+ Assert.assertEquals("class should be CMLXaxis: ", newElement.getClass(),
+ CMLXaxis.class);
+
+ }
+
+ @Test
+ public void testCMLXaxisGetAxisType() {
+ CMLXaxis cmlXaxis = new CMLXaxis();
+ Assert.assertEquals("AxisType should be X: ", CMLAxis.AxisType.X, cmlXaxis.getAxisType());
+ }
+
+}
=====================================
src/test/java/org/xmlcml/cml/element/main/CMLYaxisTest.java
=====================================
@@ -0,0 +1,63 @@
+/* Copyright 2023 Gowri Shankar K
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.xmlcml.cml.element.main;
+
+import nu.xom.Element;
+import org.junit.Assert;
+import org.junit.Test;
+import org.xmlcml.cml.base.CMLElement;
+import org.xmlcml.cml.element.CMLAxis;
+import org.xmlcml.cml.element.CMLYaxis;
+public class CMLYaxisTest {
+
+ @Test
+ public void testCMLYaxisList() {
+ CMLYaxis cmlYaxis = new CMLYaxis();
+ Assert.assertNotNull("constructor: ", cmlYaxis);
+ cmlYaxis.setAttribute("axis", "Yaxis");
+ CMLYaxis cmlYaxis1 = new CMLYaxis(cmlYaxis);
+ Assert.assertEquals("CMLYaxis attributeValue should be Yaxis: ", cmlYaxis.getAttributeValue("axis"),
+ cmlYaxis1.getAttributeValue("axis"));
+ }
+
+ @Test
+ public void testCMLYaxisCopy() {
+ CMLYaxis cmlYaxis = new CMLYaxis();
+ cmlYaxis.setAttribute("axis", "Yaxis");
+ CMLYaxis cmlYaxis1 = new CMLYaxis(cmlYaxis);
+ Element copy = cmlYaxis1.copy();
+ Assert.assertEquals("class should be CMLYaxis: ", copy.getClass(),
+ CMLYaxis.class);
+ }
+
+ @Test
+ public void testCMLYaxisMakeElementInContext() {
+ Element current = new Element("cmlYaxis");
+
+ CMLYaxis factoryElement = new CMLYaxis();
+ CMLElement newElement = factoryElement.makeElementInContext(current);
+ Assert.assertEquals("class should be CMLYaxis: ", newElement.getClass(),
+ CMLYaxis.class);
+
+ }
+
+ @Test
+ public void testCMLYaxisGetAxisType() {
+ CMLYaxis cmlYaxis = new CMLYaxis();
+ Assert.assertEquals("AxisType should be Y: ", CMLAxis.AxisType.Y, cmlYaxis.getAxisType());
+ Assert.assertNotEquals("AxisType should not be Z: ", CMLAxis.AxisType.Z, cmlYaxis.getAxisType());
+ }
+
+}
View it on GitLab: https://salsa.debian.org/java-team/cmlxom/-/commit/1651839c85361d5c16f5dc483f973bed2f0abf98
--
View it on GitLab: https://salsa.debian.org/java-team/cmlxom/-/commit/1651839c85361d5c16f5dc483f973bed2f0abf98
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20231219/f4145477/attachment.htm>
More information about the pkg-java-commits
mailing list