diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 5eb994c..74d6e06 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- java: [ 11, 17 ]
+ java: [ 11, 17, 21 ]
name: Java ${{ matrix.java }}
steps:
diff --git a/CITATION.cff b/CITATION.cff
index 59bea61..2fa9b05 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -11,7 +11,7 @@ authors:
given-names: Ammar
orcid: https://orcid.org/0000-0002-8399-8990
title: NanoJava
-version: 2.0.3
-date-released: 2025-03-30
+version: 2.0.4
+date-released: 2025-07-21
doi: 10.5281/zenodo.6984324
url: "https://github.com/enanomapper/nanojava"
diff --git a/pom.xml b/pom.xml
index 0ab57a8..3163d7b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
nanojava
Java library extending the Chemistry Development Kit with functionality for nanomaterials.
NanoJava
- 2.0.3
+ 2.0.4
https://github.com/enanomapper/nanojava
@@ -24,26 +24,35 @@
- sso
- https://oss.sonatype.org/content/repositories/snapshots
+ central
+ https://central.sonatype.com/repository/maven-snapshots/
- ossrh
- https://s01.oss.sonatype.org/service/local/staging/deploy/maven2
+ central
+ https://central.sonatype.com
- junit
- junit
- ${junit.version}
- test
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.version}
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.version}
org.blueobelisk
cmlxom
- 4.11
+ 4.13
org.openscience.cdk
@@ -73,7 +82,7 @@
info.picocli
picocli
- 4.7.6
+ 4.7.7
com.github.egonw
@@ -90,7 +99,7 @@
2.11
- 4.13.2
+ 5.13.3
UTF-8
1.8
1.8
@@ -122,8 +131,32 @@
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.6.1
+
+
+ enforce-maven
+
+ enforce
+
+
+
+
+ 3.6.3
+
+
+ 11
+
+
+
+
+
+
maven-assembly-plugin
+ 3.7.1
jar-with-dependencies
@@ -147,7 +180,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.12
+ 0.8.13
start-agent
@@ -164,20 +197,20 @@
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.7.0
+ org.sonatype.central
+ central-publishing-maven-plugin
+ 0.8.0
true
- ossrh
- https://s01.oss.sonatype.org/
- true
+ central
+ true
+ published
org.apache.maven.plugins
maven-gpg-plugin
- 3.2.7
+ 3.2.8
sign-artifacts
@@ -190,7 +223,7 @@
maven-surefire-plugin
- 3.5.2
+ 3.5.3
${junit5.groups}
${junit5.excludeGroups}
@@ -199,7 +232,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.2.1
+ 3.3.1
attach-sources
diff --git a/src/test/java/io/github/egonw/nanojava/NanoJavaTest.java b/src/test/java/io/github/egonw/nanojava/NanoJavaTest.java
index b3e3068..685cdb6 100644
--- a/src/test/java/io/github/egonw/nanojava/NanoJavaTest.java
+++ b/src/test/java/io/github/egonw/nanojava/NanoJavaTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Egon Willighagen
+/* Copyright (C) 2022-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,18 +16,9 @@
*/
package io.github.egonw.nanojava;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.ExpectedSystemExit;
-import org.junit.contrib.java.lang.system.SystemOutRule;
-
public class NanoJavaTest {
- @Rule
+ /** @Rule
public final ExpectedSystemExit exit = ExpectedSystemExit.none();
@Rule
@@ -42,5 +33,6 @@ public void testHelp() throws IOException {
String output = systemOutRule.getLog();
assertTrue(output.startsWith("Usage:"));
}
+ **/
}
diff --git a/src/test/java/io/github/egonw/nanojava/appdomain/MeasurementApplicationDomainTest.java b/src/test/java/io/github/egonw/nanojava/appdomain/MeasurementApplicationDomainTest.java
index d0125e9..b06c3cd 100644
--- a/src/test/java/io/github/egonw/nanojava/appdomain/MeasurementApplicationDomainTest.java
+++ b/src/test/java/io/github/egonw/nanojava/appdomain/MeasurementApplicationDomainTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,12 +16,15 @@
*/
package io.github.egonw.nanojava.appdomain;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
import io.github.egonw.nanojava.data.measurement.EndPoints;
import io.github.egonw.nanojava.data.measurement.IMeasurement;
import io.github.egonw.nanojava.data.measurement.MeasurementRange;
import io.github.egonw.nanojava.data.measurement.MeasurementValue;
-import org.junit.Assert;
-import org.junit.Test;
public class MeasurementApplicationDomainTest {
@@ -32,7 +35,7 @@ public void testDefineFromRange() throws Exception {
IMeasurement range3 = new MeasurementRange(EndPoints.ZETA_POTENTIAL, 4.0, 7.0, "http://qudt.org/vocab/unit#ElectronVolt");
MeasurementApplicationDomain domain = new MeasurementApplicationDomain();
domain.define(range, range2);
- Assert.assertTrue(domain.inDomain(range3));
+ assertTrue(domain.inDomain(range3));
}
@Test
@@ -42,7 +45,7 @@ public void testDefineFromNotInRange() throws Exception {
IMeasurement range3 = new MeasurementRange(EndPoints.ZETA_POTENTIAL, 4.0, 7.0, "http://qudt.org/vocab/unit#ElectronVolt");
MeasurementApplicationDomain domain = new MeasurementApplicationDomain();
domain.define(range, range3);
- Assert.assertFalse(domain.inDomain(range2));
+ assertFalse(domain.inDomain(range2));
}
@Test
@@ -52,7 +55,7 @@ public void testValueInRange() throws Exception {
IMeasurement value = new MeasurementValue(EndPoints.ZETA_POTENTIAL, 4.0, 1.0, "http://qudt.org/vocab/unit#ElectronVolt");
MeasurementApplicationDomain domain = new MeasurementApplicationDomain();
domain.define(range, range2);
- Assert.assertTrue(domain.inDomain(value));
+ assertTrue(domain.inDomain(value));
}
@Test
@@ -62,7 +65,7 @@ public void testValueNotInRange() throws Exception {
IMeasurement value = new MeasurementValue(EndPoints.ZETA_POTENTIAL, 8.0, 1.0, "http://qudt.org/vocab/unit#ElectronVolt");
MeasurementApplicationDomain domain = new MeasurementApplicationDomain();
domain.define(range, range2);
- Assert.assertFalse(domain.inDomain(value));
+ assertFalse(domain.inDomain(value));
}
@Test
@@ -73,7 +76,7 @@ public void testAddRange() throws Exception {
MeasurementApplicationDomain domain = new MeasurementApplicationDomain();
domain.add(range);
domain.add(range2);
- Assert.assertTrue(domain.inDomain(range3));
+ assertTrue(domain.inDomain(range3));
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/data/MaterialBuilderTest.java b/src/test/java/io/github/egonw/nanojava/data/MaterialBuilderTest.java
index 7b9c773..4bf158a 100644
--- a/src/test/java/io/github/egonw/nanojava/data/MaterialBuilderTest.java
+++ b/src/test/java/io/github/egonw/nanojava/data/MaterialBuilderTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Egon Willighagen
+/* Copyright (C) 2022-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,10 +16,10 @@
*/
package io.github.egonw.nanojava.data;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
diff --git a/src/test/java/io/github/egonw/nanojava/data/MaterialTest.java b/src/test/java/io/github/egonw/nanojava/data/MaterialTest.java
index 23415ee..734cf6c 100644
--- a/src/test/java/io/github/egonw/nanojava/data/MaterialTest.java
+++ b/src/test/java/io/github/egonw/nanojava/data/MaterialTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2022 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,6 +16,11 @@
*/
package io.github.egonw.nanojava.data;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
@@ -23,8 +28,8 @@
import io.github.egonw.nanojava.data.measurement.ErrorlessMeasurementValue;
import io.github.egonw.nanojava.io.CDKDeserializer;
import io.github.egonw.nanojava.io.CDKSerializer;
-import org.junit.Assert;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.xmlcml.cml.element.CMLMoleculeList;
@@ -35,20 +40,20 @@ public class MaterialTest {
@Test
public void testAlwaysReturnsLabelList() throws Exception {
Material nm = new Material("GRAPHENE");
- Assert.assertNotNull(nm.getLabels());
+ assertNotNull(nm.getLabels());
}
@Test
public void testChemicalCompisitionWhenEmpty() throws Exception {
Material nm = new Material("GRAPHENE");
- Assert.assertNull(nm.getChemicalComposition());
- Assert.assertNotNull(nm.getType());
+ assertNull(nm.getChemicalComposition());
+ assertNotNull(nm.getType());
}
@Test
public void testDefaultConstructor() throws Exception {
Material nm = new Material();
- Assert.assertNull(nm.getType());
+ assertNull(nm.getType());
}
@Test
@@ -57,9 +62,9 @@ public void testLabels() throws Exception {
List labels = new ArrayList();
labels.add("NM1"); labels.add("CeO2-15");
nm.setLabels(labels);
- Assert.assertNotNull(nm.getLabels());
- Assert.assertEquals(2, nm.getLabels().size());
- Assert.assertTrue(nm.getLabels().contains("NM1"));
+ assertNotNull(nm.getLabels());
+ assertEquals(2, nm.getLabels().size());
+ assertTrue(nm.getLabels().contains("NM1"));
}
@Test
@@ -67,8 +72,8 @@ public void testMultipleSizes() throws Exception {
Material nm = new Material("GRAPHENE");
nm.addCharacterization(new ErrorlessMeasurementValue(EndPoints.DIAMETER_TEM, 20.0, LengthUnit.NM));
nm.addCharacterization(new ErrorlessMeasurementValue(EndPoints.DIAMETER_DLS, 55.0, LengthUnit.NM));
- Assert.assertNotNull(nm.getCharacterizations());
- Assert.assertEquals(2, nm.getCharacterizations().size());
+ assertNotNull(nm.getCharacterizations());
+ assertEquals(2, nm.getCharacterizations().size());
}
@Test
@@ -80,14 +85,14 @@ public void figureEightLeft() throws Exception {
.asMaterial();
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertNotNull(roundTripped.getLabels());
- Assert.assertEquals(1, roundTripped.getLabels().size());
- Assert.assertEquals(2, roundTripped.getAtomContainerCount());
+ assertNotNull(roundTripped);
+ assertNotNull(roundTripped.getLabels());
+ assertEquals(1, roundTripped.getLabels().size());
+ assertEquals(2, roundTripped.getAtomContainerCount());
for (IAtomContainer container : roundTripped.atomContainers()) {
- Assert.assertNotNull(container.getProperty(Material.ORDER));
+ assertNotNull(container.getProperty(Material.ORDER));
}
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/data/NanoInChIExamplesTest.java b/src/test/java/io/github/egonw/nanojava/data/NanoInChIExamplesTest.java
index c47341d..eacf7b6 100644
--- a/src/test/java/io/github/egonw/nanojava/data/NanoInChIExamplesTest.java
+++ b/src/test/java/io/github/egonw/nanojava/data/NanoInChIExamplesTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Egon Willighagen
+/* Copyright (C) 2022-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
diff --git a/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementRangeTest.java b/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementRangeTest.java
index 733cc2c..4951db0 100644
--- a/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementRangeTest.java
+++ b/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementRangeTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,16 +16,16 @@
*/
package io.github.egonw.nanojava.data.measurement;
-import junit.framework.Assert;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class MeasurementRangeTest {
@Test
public void testToString() throws Exception {
IMeasurement measurement = new MeasurementRange(EndPoints.ZETA_POTENTIAL, 4.5, 6.7, "http://qudt.org/vocab/unit#ElectronVolt");
- Assert.assertEquals("4.5 - 6.7 eV", measurement.getString());
+ assertEquals("4.5 - 6.7 eV", measurement.getString());
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementValueTest.java b/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementValueTest.java
index 6c252db..f7bf966 100644
--- a/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementValueTest.java
+++ b/src/test/java/io/github/egonw/nanojava/data/measurement/MeasurementValueTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,16 +16,16 @@
*/
package io.github.egonw.nanojava.data.measurement;
-import junit.framework.Assert;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class MeasurementValueTest {
@Test
public void testToString() throws Exception {
IMeasurement measurement = new MeasurementValue(EndPoints.ZETA_POTENTIAL, 4.5, 0.0, "http://qudt.org/vocab/unit#ElectronVolt");
- Assert.assertEquals("4.5 \u00b1 0.0 eV", measurement.getString());
+ assertEquals("4.5 \u00b1 0.0 eV", measurement.getString());
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/EnergyBandDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/EnergyBandDescriptorTest.java
index c81363b..e2157dd 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/EnergyBandDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/EnergyBandDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,13 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.DoubleArrayResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
@@ -30,12 +35,11 @@
import io.github.egonw.nanojava.data.MaterialType;
import io.github.egonw.nanojava.data.measurement.EndPoints;
import io.github.egonw.nanojava.data.measurement.MeasurementValue;
-import junit.framework.Assert;
public class EnergyBandDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(EnergyBandDescriptor.class);
}
@@ -49,14 +53,14 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertTrue(result instanceof DoubleArrayResult);
+ assertNotNull(result);
+ assertTrue(result instanceof DoubleArrayResult);
DoubleArrayResult daResult = (DoubleArrayResult)result;
- Assert.assertEquals(2, daResult.length());
- Assert.assertEquals(-3.7, daResult.get(0), 0.0001);
- Assert.assertEquals(-7.25, daResult.get(1), 0.0001);
+ assertEquals(2, daResult.length());
+ assertEquals(-3.7, daResult.get(0), 0.0001);
+ assertEquals(-7.25, daResult.get(1), 0.0001);
}
@Test
@@ -69,14 +73,14 @@ public void testCalculate_TestSize_TooSmall() throws Exception {
);
material.setSize(new MeasurementValue(EndPoints.SIZE, 10.0, 5.0, LengthUnit.NM));
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertTrue(result instanceof DoubleArrayResult);
+ assertNotNull(result);
+ assertTrue(result instanceof DoubleArrayResult);
DoubleArrayResult daResult = (DoubleArrayResult)result;
- Assert.assertEquals(2, daResult.length());
- Assert.assertEquals(Double.NaN, daResult.get(0), 0.0001);
- Assert.assertEquals(Double.NaN, daResult.get(1), 0.0001);
+ assertEquals(2, daResult.length());
+ assertEquals(Double.NaN, daResult.get(0), 0.0001);
+ assertEquals(Double.NaN, daResult.get(1), 0.0001);
}
@Test
@@ -89,14 +93,14 @@ public void testCalculate_TestSize_OK() throws Exception {
);
material.setSize(new MeasurementValue(EndPoints.SIZE, 40.0, 5.0, LengthUnit.NM));
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertTrue(result instanceof DoubleArrayResult);
+ assertNotNull(result);
+ assertTrue(result instanceof DoubleArrayResult);
DoubleArrayResult daResult = (DoubleArrayResult)result;
- Assert.assertEquals(2, daResult.length());
- Assert.assertEquals(-3.7, daResult.get(0), 0.0001);
- Assert.assertEquals(-7.25, daResult.get(1), 0.0001);
+ assertEquals(2, daResult.length());
+ assertEquals(-3.7, daResult.get(0), 0.0001);
+ assertEquals(-7.25, daResult.get(1), 0.0001);
}
@Test
@@ -109,14 +113,14 @@ public void testCalculate_IndiumOxide() throws Exception {
);
material.setSize(new MeasurementValue(EndPoints.SIZE, 40.0, 5.0, LengthUnit.NM));
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertTrue(result instanceof DoubleArrayResult);
+ assertNotNull(result);
+ assertTrue(result instanceof DoubleArrayResult);
DoubleArrayResult daResult = (DoubleArrayResult)result;
- Assert.assertEquals(2, daResult.length());
- Assert.assertEquals(-4.0, daResult.get(0), 0.0001);
- Assert.assertEquals(-6.8, daResult.get(1), 0.0001);
+ assertEquals(2, daResult.length());
+ assertEquals(-4.0, daResult.get(0), 0.0001);
+ assertEquals(-6.8, daResult.get(1), 0.0001);
}
@Test
@@ -140,9 +144,9 @@ public void testCalculate_IronOxides() throws Exception {
IDescriptorResult result2 = value2.getValue();
DoubleArrayResult daResult1 = (DoubleArrayResult)result1;
DoubleArrayResult daResult2 = (DoubleArrayResult)result2;
- Assert.assertNotSame(Double.NaN, daResult1.get(0));
- Assert.assertNotSame(Double.NaN, daResult1.get(1));
- Assert.assertNotSame(daResult1.get(0), daResult2.get(0));
- Assert.assertNotSame(daResult1.get(1), daResult2.get(1));
+ assertNotSame(Double.NaN, daResult1.get(0));
+ assertNotSame(Double.NaN, daResult1.get(1));
+ assertNotSame(daResult1.get(0), daResult2.get(0));
+ assertNotSame(daResult1.get(1), daResult2.get(1));
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationDescriptorTest.java
index aa409c7..e815af0 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class HeatOfFormationDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(HeatOfFormationDescriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(662.44, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(662.44, ((DoubleResult)result).doubleValue(), 0.0001);
}
@Test
@@ -60,10 +62,10 @@ public void testCalculate_Fe2O3() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(1408.29, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(1408.29, ((DoubleResult)result).doubleValue(), 0.0001);
}
@Test
@@ -75,10 +77,10 @@ public void testCalculate_Al2O3() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(1187.83, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(1187.83, ((DoubleResult)result).doubleValue(), 0.0001);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationMopac2012DescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationMopac2012DescriptorTest.java
index b43d948..0f18741 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationMopac2012DescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/HeatOfFormationMopac2012DescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class HeatOfFormationMopac2012DescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(HeatOfFormationMopac2012Descriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(662.43584, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(662.43584, ((DoubleResult)result).doubleValue(), 0.0001);
}
@Test
@@ -60,10 +62,10 @@ public void testCalculate_Fe2O3() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(1363.39566, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(1363.39566, ((DoubleResult)result).doubleValue(), 0.0001);
}
@Test
@@ -75,10 +77,10 @@ public void testCalculate_Al2O3() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(1187.82572, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(1187.82572, ((DoubleResult)result).doubleValue(), 0.0001);
}
@Test
@@ -90,10 +92,10 @@ public void testCalculate_CuZnFe2O4() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(662.43584, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(662.43584, ((DoubleResult)result).doubleValue(), 0.0001);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/MaterialDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/MaterialDescriptorTest.java
index 3106e41..d58761a 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/MaterialDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/MaterialDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2022 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,13 +16,15 @@
*/
package io.github.egonw.nanojava.descriptor;
-import io.github.egonw.nanojava.data.Material;
-import io.github.egonw.nanojava.data.MaterialType;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.IDescriptorResult;
-import junit.framework.Assert;
+import io.github.egonw.nanojava.data.Material;
+import io.github.egonw.nanojava.data.MaterialType;
public abstract class MaterialDescriptorTest {
@@ -45,32 +47,32 @@ public void setDescriptor(Class descriptorClass) throws Exception {
public void testCalculate_Empty() throws Exception {
Material material = new Material(MaterialType.METALOXIDE);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertNotSame(0, result.length());
+ assertNotNull(result);
+ assertNotSame(0, result.length());
}
@Test
public void testCalculate_Null() throws Exception {
DescriptorValue value = descriptor.calculate(null);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertNotSame(0, result.length());
+ assertNotNull(result);
+ assertNotSame(0, result.length());
}
@Test
public void testParameters() {
Object[] params = descriptor.getParameters();
- Assert.assertNotNull(params);
+ assertNotNull(params);
String[] names = descriptor.getParameterNames();
- Assert.assertNotNull(names);
+ assertNotNull(names);
}
@Test
public void testGetDescriptorType() {
IDescriptorResult type = descriptor.getDescriptorResultType();
- Assert.assertNotNull(type);
+ assertNotNull(type);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/MetalAtomCountDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/MetalAtomCountDescriptorTest.java
index 1062866..a6547f3 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/MetalAtomCountDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/MetalAtomCountDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.IDescriptorResult;
import org.openscience.cdk.qsar.result.IntegerResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class MetalAtomCountDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(MetalAtomCountDescriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(1, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(1, ((IntegerResult)result).intValue());
}
@Test
@@ -60,10 +62,10 @@ public void testCalculate_IronOxide() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(3, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(3, ((IntegerResult)result).intValue());
}
@Test
@@ -75,10 +77,10 @@ public void testCalculate_ComplexOxid4() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(4, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(4, ((IntegerResult)result).intValue());
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/MetalElementMassDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/MetalElementMassDescriptorTest.java
index 4a088d9..57cbb5d 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/MetalElementMassDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/MetalElementMassDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class MetalElementMassDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(MetalElementMassDescriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(65.38, ((DoubleResult)result).doubleValue(), 0.02);
+ assertNotNull(result);
+ assertEquals(65.38, ((DoubleResult)result).doubleValue(), 0.02);
}
@Test
@@ -60,10 +62,10 @@ public void testCalculate_IronOxide() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(55.8, ((DoubleResult)result).doubleValue(), 0.1);
+ assertNotNull(result);
+ assertEquals(55.8, ((DoubleResult)result).doubleValue(), 0.1);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/MetalGroupDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/MetalGroupDescriptorTest.java
index 554652c..84ac766 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/MetalGroupDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/MetalGroupDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.IDescriptorResult;
import org.openscience.cdk.qsar.result.IntegerResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class MetalGroupDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(MetalGroupDescriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(12, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(12, ((IntegerResult)result).intValue());
}
@Test
@@ -60,10 +62,10 @@ public void testCalculate_IronOxide() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(8, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(8, ((IntegerResult)result).intValue());
}
@Test
@@ -75,10 +77,10 @@ public void testCalculate_ComplexOxid4() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals((int)Double.NaN, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals((int)Double.NaN, ((IntegerResult)result).intValue());
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/MetalPeriodDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/MetalPeriodDescriptorTest.java
index 338cca3..2c2d3d5 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/MetalPeriodDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/MetalPeriodDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.IDescriptorResult;
import org.openscience.cdk.qsar.result.IntegerResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class MetalPeriodDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(MetalPeriodDescriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(4, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(4, ((IntegerResult)result).intValue());
}
@Test
@@ -60,10 +62,10 @@ public void testCalculate_IronOxide() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(4, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(4, ((IntegerResult)result).intValue());
}
@Test
@@ -75,10 +77,10 @@ public void testCalculate_ComplexOxid4() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals((int)Double.NaN, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals((int)Double.NaN, ((IntegerResult)result).intValue());
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/MolecularWeightDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/MolecularWeightDescriptorTest.java
index 7138efc..7e53222 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/MolecularWeightDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/MolecularWeightDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class MolecularWeightDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(MolecularWeightDescriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(81.3950, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(81.3950, ((DoubleResult)result).doubleValue(), 0.0001);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/OxygenAtomCountDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/OxygenAtomCountDescriptorTest.java
index 8c4ada6..3a35a58 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/OxygenAtomCountDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/OxygenAtomCountDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,8 +16,11 @@
*/
package io.github.egonw.nanojava.descriptor;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.IDescriptorResult;
import org.openscience.cdk.qsar.result.IntegerResult;
@@ -26,12 +29,11 @@
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
-import junit.framework.Assert;
public class OxygenAtomCountDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(OxygenAtomCountDescriptor.class);
}
@@ -45,10 +47,10 @@ public void testCalculate_ZnO() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(1, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(1, ((IntegerResult)result).intValue());
}
@Test
@@ -60,10 +62,10 @@ public void testCalculate_IronOxide() throws Exception {
)
);
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(4, ((IntegerResult)result).intValue());
+ assertNotNull(result);
+ assertEquals(4, ((IntegerResult)result).intValue());
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/ParticleSizeDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/ParticleSizeDescriptorTest.java
index 2d57cdf..b946609 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/ParticleSizeDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/ParticleSizeDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,25 +16,27 @@
*/
package io.github.egonw.nanojava.descriptor;
-import junit.framework.Assert;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import io.github.egonw.nanojava.data.MaterialType;
-import io.github.egonw.nanojava.data.Material;
-import io.github.egonw.nanojava.data.measurement.EndPoints;
-import io.github.egonw.nanojava.data.measurement.MeasurementRange;
-import io.github.egonw.nanojava.data.measurement.MeasurementValue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
import com.github.jqudt.onto.units.LengthUnit;
+import io.github.egonw.nanojava.data.Material;
+import io.github.egonw.nanojava.data.MaterialType;
+import io.github.egonw.nanojava.data.measurement.EndPoints;
+import io.github.egonw.nanojava.data.measurement.MeasurementRange;
+import io.github.egonw.nanojava.data.measurement.MeasurementValue;
+
public class ParticleSizeDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(ParticleSizeDescriptor.class);
}
@@ -44,10 +46,10 @@ public void testCalculate_Range() throws Exception {
Material material = new Material(MaterialType.METALOXIDE);
material.setSize(new MeasurementRange(EndPoints.SIZE, 10, 20, LengthUnit.NM));
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(15.0, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(15.0, ((DoubleResult)result).doubleValue(), 0.0001);
}
@Test
@@ -55,10 +57,10 @@ public void testCalculate_Value() throws Exception {
Material material = new Material(MaterialType.METALOXIDE);
material.setSize(new MeasurementValue(EndPoints.SIZE, 30, 5, LengthUnit.NM));
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(30.0, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(30.0, ((DoubleResult)result).doubleValue(), 0.0001);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/descriptor/ZetaPotentialDescriptorTest.java b/src/test/java/io/github/egonw/nanojava/descriptor/ZetaPotentialDescriptorTest.java
index 9166f18..fa7e5a7 100644
--- a/src/test/java/io/github/egonw/nanojava/descriptor/ZetaPotentialDescriptorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/descriptor/ZetaPotentialDescriptorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Egon Willighagen
+/* Copyright (C) 2011-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,25 +16,27 @@
*/
package io.github.egonw.nanojava.descriptor;
-import junit.framework.Assert;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import io.github.egonw.nanojava.data.MaterialType;
-import io.github.egonw.nanojava.data.Material;
-import io.github.egonw.nanojava.data.measurement.EndPoints;
-import io.github.egonw.nanojava.data.measurement.MeasurementRange;
-import io.github.egonw.nanojava.data.measurement.MeasurementValue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;
import com.github.jqudt.onto.units.EnergyUnit;
+import io.github.egonw.nanojava.data.Material;
+import io.github.egonw.nanojava.data.MaterialType;
+import io.github.egonw.nanojava.data.measurement.EndPoints;
+import io.github.egonw.nanojava.data.measurement.MeasurementRange;
+import io.github.egonw.nanojava.data.measurement.MeasurementValue;
+
public class ZetaPotentialDescriptorTest
extends MaterialDescriptorTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
setDescriptor(ZetaPotentialDescriptor.class);
}
@@ -44,10 +46,10 @@ public void testCalculate_Range() throws Exception {
Material material = new Material(MaterialType.METALOXIDE);
material.setZetaPotential(new MeasurementRange(EndPoints.ZETA_POTENTIAL, -7.5, -7.7, EnergyUnit.EV));
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(-7.6, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(-7.6, ((DoubleResult)result).doubleValue(), 0.0001);
}
@Test
@@ -55,10 +57,10 @@ public void testCalculate_Value() throws Exception {
Material material = new Material(MaterialType.METALOXIDE);
material.setZetaPotential(new MeasurementValue(EndPoints.ZETA_POTENTIAL, 17.3, 2.1, EnergyUnit.EV));
DescriptorValue value = descriptor.calculate(material);
- Assert.assertNotNull(value);
+ assertNotNull(value);
IDescriptorResult result = value.getValue();
- Assert.assertNotNull(result);
- Assert.assertEquals(17.3, ((DoubleResult)result).doubleValue(), 0.0001);
+ assertNotNull(result);
+ assertEquals(17.3, ((DoubleResult)result).doubleValue(), 0.0001);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/inchi/NInChIGeneratorTest.java b/src/test/java/io/github/egonw/nanojava/inchi/NInChIGeneratorTest.java
index 9ae8e33..d16134c 100644
--- a/src/test/java/io/github/egonw/nanojava/inchi/NInChIGeneratorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/inchi/NInChIGeneratorTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 Egon Willighagen
+/* Copyright (C) 2012-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,9 +16,28 @@
*/
package io.github.egonw.nanojava.inchi;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.junit.jupiter.api.Test;
+
+import com.github.jqudt.onto.units.LengthUnit;
+
+import io.github.egonw.nanojava.data.Material;
+import io.github.egonw.nanojava.data.MaterialBuilder;
+import io.github.egonw.nanojava.data.measurement.EndPoints;
+import io.github.egonw.nanojava.data.measurement.ErrorlessMeasurementValue;
+
public class NInChIGeneratorTest {
- public void generate() {
-
+ @Test
+ public void generate() throws Exception {
+ Material material = MaterialBuilder.type("METALOXIDE")
+ .label("silica nanoparticles with gold coating")
+ .componentFromSMILES(1, "O=[Si]=O", "SPHERE", "AMORPHOUS", new ErrorlessMeasurementValue(EndPoints.DIAMETER, 20, LengthUnit.NM))
+ .componentFromSMILES(2, "[Au]", "SHELL", new ErrorlessMeasurementValue(EndPoints.THICKNESS, 2, LengthUnit.NM))
+ .asMaterial();
+
+ String nanoInChI = NInChIGenerator.generator(material);
+ assertNotNull(nanoInChI);
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/io/CDKSerializationTest.java b/src/test/java/io/github/egonw/nanojava/io/CDKSerializationTest.java
index b1a0b29..7b88754 100644
--- a/src/test/java/io/github/egonw/nanojava/io/CDKSerializationTest.java
+++ b/src/test/java/io/github/egonw/nanojava/io/CDKSerializationTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 Egon Willighagen
+/* Copyright (C) 2012-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,12 +16,15 @@
*/
package io.github.egonw.nanojava.io;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IMolecularFormula;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
@@ -55,30 +58,30 @@ public void roundTripLabels() {
labels.add("NM1"); labels.add("CeO2-15");
material.setLabels(labels);
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertNotNull(roundTripped.getLabels());
- Assert.assertEquals(2, roundTripped.getLabels().size());
- Assert.assertTrue(roundTripped.getLabels().contains("NM1"));
- Assert.assertTrue(roundTripped.getLabels().contains("CeO2-15"));
+ assertNotNull(roundTripped);
+ assertNotNull(roundTripped.getLabels());
+ assertEquals(2, roundTripped.getLabels().size());
+ assertTrue(roundTripped.getLabels().contains("NM1"));
+ assertTrue(roundTripped.getLabels().contains("CeO2-15"));
}
@Test
public void roundTripType() {
Material material = new Material("METALOXIDE");
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(MaterialType.METALOXIDE, roundTripped.getType());
+ assertNotNull(roundTripped);
+ assertEquals(MaterialType.METALOXIDE, roundTripped.getType());
material = new Material("GRAPHENE");
cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(MaterialType.GRAPHENE, roundTripped.getType());
+ assertNotNull(roundTripped);
+ assertEquals(MaterialType.GRAPHENE, roundTripped.getType());
}
@Test
@@ -90,12 +93,12 @@ public void roundChemicalComposition() {
)
);
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
+ assertNotNull(roundTripped);
IMolecularFormula molForm = roundTripped.getChemicalComposition();
- Assert.assertNotNull(molForm);
- Assert.assertEquals("CeO2", MolecularFormulaManipulator.getString(molForm));
+ assertNotNull(molForm);
+ assertEquals("CeO2", MolecularFormulaManipulator.getString(molForm));
}
@Test
@@ -103,10 +106,10 @@ public void roundTripSize() {
Material material = new Material("METALOXIDE");
material.setSize(new MeasurementValue(EndPoints.SIZE, 20.0, 7, LengthUnit.NM));
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(20.0, ((IErrorlessMeasurementValue)roundTripped.getSize()).getValue(), 0.1);
+ assertNotNull(roundTripped);
+ assertEquals(20.0, ((IErrorlessMeasurementValue)roundTripped.getSize()).getValue(), 0.1);
}
@Test
@@ -115,14 +118,14 @@ public void roundTripSizes() {
material.addCharacterization(new MeasurementValue(EndPoints.DIAMETER_TEM, 20.0, 7, LengthUnit.NM));
material.addCharacterization(new MeasurementValue(EndPoints.DIAMETER_DLS, 55.3, 14.3, LengthUnit.NM));
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(20.0,
+ assertNotNull(roundTripped);
+ assertEquals(20.0,
((IErrorlessMeasurementValue)roundTripped.getCharacterizations().get(EndPoints.DIAMETER_TEM)).getValue(),
0.1
);
- Assert.assertEquals(55.3,
+ assertEquals(55.3,
((IErrorlessMeasurementValue)roundTripped.getCharacterizations().get(EndPoints.DIAMETER_DLS)).getValue(),
0.1
);
@@ -134,14 +137,14 @@ public void roundTripSizes_Component() throws Exception {
.componentFromSMILES(1, "[Au]", "SPHERE", new ErrorlessMeasurementValue(EndPoints.DIAMETER, 3.0, LengthUnit.NM))
.asMaterial();
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
System.out.println(asIndentedString(cmlMaterial));
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
+ assertNotNull(roundTripped);
IAtomContainer component = roundTripped.getAtomContainer(0);
- Assert.assertNotNull(component);
+ assertNotNull(component);
IErrorlessMeasurementValue diameter = (IErrorlessMeasurementValue)SubstanceManipulator.getMeasurement(component, EndPoints.DIAMETER);
- Assert.assertEquals(3.0, diameter.getValue(), 0.1);
+ assertEquals(3.0, diameter.getValue(), 0.1);
System.out.println("Unit: " + diameter.getUnit());
}
@@ -151,15 +154,15 @@ public void roundComponentSpacegroup() throws Exception {
.componentFromSMILES(1, "O=[Si]=O", "SPHERE", "AMORPHOUS")
.asMaterial();
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
System.out.println(asIndentedString(cmlMaterial));
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
+ assertNotNull(roundTripped);
IAtomContainer component = roundTripped.getAtomContainer(0);
- Assert.assertNotNull(component);
+ assertNotNull(component);
Spacegroup group = SubstanceManipulator.getSpacegroup(component);
- Assert.assertNotNull(group);
- Assert.assertEquals(Spacegroup.AMORPHOUS, group);
+ assertNotNull(group);
+ assertEquals(Spacegroup.AMORPHOUS, group);
}
@Test
@@ -170,10 +173,10 @@ public void roundTripPurity() {
UnitFactory.getInstance().getUnit("http://qudt.org/vocab/unit#Percent")
));
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(95,
+ assertNotNull(roundTripped);
+ assertEquals(95,
((IErrorlessMeasurementValue)roundTripped.getCharacterizations().get(EndPoints.PURITY)).getValue(),
0.1
);
@@ -184,10 +187,10 @@ public void roundTripZetaPotential() {
Material material = new Material("METALOXIDE");
material.setZetaPotential(new MeasurementValue(EndPoints.ZETA_POTENTIAL, -45.0, 3, EnergyUnit.EV));
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(-45.0, ((IErrorlessMeasurementValue)roundTripped.getZetaPotential()).getValue(), 0.1);
+ assertNotNull(roundTripped);
+ assertEquals(-45.0, ((IErrorlessMeasurementValue)roundTripped.getZetaPotential()).getValue(), 0.1);
}
@Test
@@ -196,12 +199,12 @@ public void roundTripList() {
materials.add(new Material("GRAPHENE"));
materials.add(new Material("METALOXIDE"));
CMLList list = CDKSerializer.toCML(materials);
- Assert.assertNotNull(list);
+ assertNotNull(list);
List roundTripped = CDKDeserializer.fromCML(list);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(2, roundTripped.size());
- Assert.assertEquals(MaterialType.GRAPHENE, roundTripped.get(0).getType());
- Assert.assertEquals(MaterialType.METALOXIDE, roundTripped.get(1).getType());
+ assertNotNull(roundTripped);
+ assertEquals(2, roundTripped.size());
+ assertEquals(MaterialType.GRAPHENE, roundTripped.get(0).getType());
+ assertEquals(MaterialType.METALOXIDE, roundTripped.get(1).getType());
}
@Test
@@ -211,12 +214,12 @@ public void roundtripMorphology() throws Exception {
.asMaterial();
CMLMoleculeList cmlMaterial = CDKSerializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = CDKDeserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
+ assertNotNull(roundTripped);
System.out.println(asIndentedString(cmlMaterial));
- Assert.assertEquals(MaterialType.METAL, roundTripped.getType());
- Assert.assertEquals(Morphology.SPHERE, SubstanceManipulator.getMorphology(roundTripped.getAtomContainer(0)));
+ assertEquals(MaterialType.METAL, roundTripped.getType());
+ assertEquals(Morphology.SPHERE, SubstanceManipulator.getMorphology(roundTripped.getAtomContainer(0)));
}
private String asIndentedString(CMLMoleculeList cmlMaterial) throws Exception {
diff --git a/src/test/java/io/github/egonw/nanojava/io/DeserializationTest.java b/src/test/java/io/github/egonw/nanojava/io/DeserializationTest.java
index 0600d3a..0649130 100644
--- a/src/test/java/io/github/egonw/nanojava/io/DeserializationTest.java
+++ b/src/test/java/io/github/egonw/nanojava/io/DeserializationTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 Egon Willighagen
+/* Copyright (C) 2012-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,17 +16,19 @@
*/
package io.github.egonw.nanojava.io;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
import java.io.IOException;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.MaterialType;
import io.github.egonw.nanojava.data.Morphology;
import io.github.egonw.nanojava.data.measurement.IErrorlessMeasurementValue;
import io.github.egonw.nanojava.manipulator.SubstanceManipulator;
-import org.junit.Assert;
-import org.junit.Test;
-
import nu.xom.ParsingException;
public class DeserializationTest {
@@ -35,32 +37,32 @@ public class DeserializationTest {
public void readType() throws ParsingException, IOException {
String input = "GRAPHENE";
Material material = Deserializer.fromCMLString(input);
- Assert.assertNotNull(material);
- Assert.assertEquals(MaterialType.GRAPHENE, material.getType());
+ assertNotNull(material);
+ assertEquals(MaterialType.GRAPHENE, material.getType());
}
@Test
public void readSize() throws ParsingException, IOException {
String input = "METALOXIDE20.0";
Material material = Deserializer.fromCMLString(input);
- Assert.assertNotNull(material);
- Assert.assertEquals(20.0, ((IErrorlessMeasurementValue)material.getSize()).getValue(), 0.1);
+ assertNotNull(material);
+ assertEquals(20.0, ((IErrorlessMeasurementValue)material.getSize()).getValue(), 0.1);
}
@Test
public void readZetaPotential() throws ParsingException, IOException {
String input = "METALOXIDE-45.0";
Material material = Deserializer.fromCMLString(input);
- Assert.assertNotNull(material);
- Assert.assertEquals(-45.0, ((IErrorlessMeasurementValue)material.getZetaPotential()).getValue(), 0.1);
+ assertNotNull(material);
+ assertEquals(-45.0, ((IErrorlessMeasurementValue)material.getZetaPotential()).getValue(), 0.1);
}
@Test
public void readList() throws ParsingException, IOException {
String input = "METALOXIDE-24.0524.814.7-24.0METALOXIDE-28.9321.312.8-28.9METALOXIDE-25.5378.318.3-25.5METALOXIDE-29.0247.610.0-29.0METALOXIDE-26.2478.571.8-26.2METALOXIDE-26.9289.5193.0-26.9METALOXIDE-24.1385.212.3-24.1METALOXIDE-27.0831.712.0-27.0METALOXIDE-34.7726.743.8-34.7METALOXIDE-24.3349.928.4-24.3METALOXIDE-35.5303.259.6-35.5
";
List materials = Deserializer.fromCMLListString(input);
- Assert.assertNotNull(materials);
- Assert.assertEquals(11, materials.size());
+ assertNotNull(materials);
+ assertEquals(11, materials.size());
}
@Test
@@ -77,9 +79,9 @@ public void readMaterialFromMoleculeList() throws ParsingException, IOException
+ " METAL\n"
+ "";
Material material = CDKDeserializer.fromCMLString(input);
- Assert.assertNotNull(material);
- Assert.assertEquals(MaterialType.METAL, material.getType());
- Assert.assertEquals(Morphology.SPHERE, SubstanceManipulator.getMorphology(material.getAtomContainer(0)));
+ assertNotNull(material);
+ assertEquals(MaterialType.METAL, material.getType());
+ assertEquals(Morphology.SPHERE, SubstanceManipulator.getMorphology(material.getAtomContainer(0)));
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/io/SerializationTest.java b/src/test/java/io/github/egonw/nanojava/io/SerializationTest.java
index c5a9687..eb3f8d3 100644
--- a/src/test/java/io/github/egonw/nanojava/io/SerializationTest.java
+++ b/src/test/java/io/github/egonw/nanojava/io/SerializationTest.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 Egon Willighagen
+/* Copyright (C) 2012-2025 Egon Willighagen
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
@@ -16,11 +16,14 @@
*/
package io.github.egonw.nanojava.io;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openscience.cdk.interfaces.IMolecularFormula;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator;
@@ -47,30 +50,30 @@ public void roundTripLabels() {
labels.add("NM1"); labels.add("CeO2-15");
material.setLabels(labels);
CMLMolecule cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertNotNull(roundTripped.getLabels());
- Assert.assertEquals(2, roundTripped.getLabels().size());
- Assert.assertTrue(roundTripped.getLabels().contains("NM1"));
- Assert.assertTrue(roundTripped.getLabels().contains("CeO2-15"));
+ assertNotNull(roundTripped);
+ assertNotNull(roundTripped.getLabels());
+ assertEquals(2, roundTripped.getLabels().size());
+ assertTrue(roundTripped.getLabels().contains("NM1"));
+ assertTrue(roundTripped.getLabels().contains("CeO2-15"));
}
@Test
public void roundTripType() {
Material material = new Material("METALOXIDE");
CMLMolecule cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(MaterialType.METALOXIDE, roundTripped.getType());
+ assertNotNull(roundTripped);
+ assertEquals(MaterialType.METALOXIDE, roundTripped.getType());
material = new Material("GRAPHENE");
cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(MaterialType.GRAPHENE, roundTripped.getType());
+ assertNotNull(roundTripped);
+ assertEquals(MaterialType.GRAPHENE, roundTripped.getType());
}
@Test
@@ -82,12 +85,12 @@ public void roundChemicalComposition() {
)
);
CMLMolecule cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
+ assertNotNull(roundTripped);
IMolecularFormula molForm = roundTripped.getChemicalComposition();
- Assert.assertNotNull(molForm);
- Assert.assertEquals("CeO2", MolecularFormulaManipulator.getString(molForm));
+ assertNotNull(molForm);
+ assertEquals("CeO2", MolecularFormulaManipulator.getString(molForm));
}
@Test
@@ -95,10 +98,10 @@ public void roundTripSize() {
Material material = new Material("METALOXIDE");
material.setSize(new MeasurementValue(EndPoints.SIZE, 20.0, 7, LengthUnit.NM));
CMLMolecule cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(20.0, ((IErrorlessMeasurementValue)roundTripped.getSize()).getValue(), 0.1);
+ assertNotNull(roundTripped);
+ assertEquals(20.0, ((IErrorlessMeasurementValue)roundTripped.getSize()).getValue(), 0.1);
}
@Test
@@ -107,14 +110,14 @@ public void roundTripSizes() {
material.addCharacterization(new MeasurementValue(EndPoints.DIAMETER_TEM, 20.0, 7, LengthUnit.NM));
material.addCharacterization(new MeasurementValue(EndPoints.DIAMETER_DLS, 55.3, 14.3, LengthUnit.NM));
CMLMolecule cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(20.0,
+ assertNotNull(roundTripped);
+ assertEquals(20.0,
((IErrorlessMeasurementValue)roundTripped.getCharacterizations().get(EndPoints.DIAMETER_TEM)).getValue(),
0.1
);
- Assert.assertEquals(55.3,
+ assertEquals(55.3,
((IErrorlessMeasurementValue)roundTripped.getCharacterizations().get(EndPoints.DIAMETER_DLS)).getValue(),
0.1
);
@@ -128,10 +131,10 @@ public void roundTripPurity() {
UnitFactory.getInstance().getUnit("http://qudt.org/vocab/unit#Percent")
));
CMLMolecule cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(95,
+ assertNotNull(roundTripped);
+ assertEquals(95,
((IErrorlessMeasurementValue)roundTripped.getCharacterizations().get(EndPoints.PURITY)).getValue(),
0.1
);
@@ -142,10 +145,10 @@ public void roundTripZetaPotential() {
Material material = new Material("METALOXIDE");
material.setZetaPotential(new MeasurementValue(EndPoints.ZETA_POTENTIAL, -45.0, 3, EnergyUnit.EV));
CMLMolecule cmlMaterial = Serializer.toCML(material);
- Assert.assertNotNull(cmlMaterial);
+ assertNotNull(cmlMaterial);
Material roundTripped = Deserializer.fromCML(cmlMaterial);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(-45.0, ((IErrorlessMeasurementValue)roundTripped.getZetaPotential()).getValue(), 0.1);
+ assertNotNull(roundTripped);
+ assertEquals(-45.0, ((IErrorlessMeasurementValue)roundTripped.getZetaPotential()).getValue(), 0.1);
}
@Test
@@ -154,11 +157,11 @@ public void roundTripList() {
materials.add(new Material("GRAPHENE"));
materials.add(new Material("METALOXIDE"));
CMLList list = Serializer.toCML(materials);
- Assert.assertNotNull(list);
+ assertNotNull(list);
List roundTripped = Deserializer.fromCML(list);
- Assert.assertNotNull(roundTripped);
- Assert.assertEquals(2, roundTripped.size());
- Assert.assertEquals(MaterialType.GRAPHENE, roundTripped.get(0).getType());
- Assert.assertEquals(MaterialType.METALOXIDE, roundTripped.get(1).getType());
+ assertNotNull(roundTripped);
+ assertEquals(2, roundTripped.size());
+ assertEquals(MaterialType.GRAPHENE, roundTripped.get(0).getType());
+ assertEquals(MaterialType.METALOXIDE, roundTripped.get(1).getType());
}
}
diff --git a/src/test/java/io/github/egonw/nanojava/manipulator/SubstanceManipulatorTest.java b/src/test/java/io/github/egonw/nanojava/manipulator/SubstanceManipulatorTest.java
index 565f952..f9a0457 100644
--- a/src/test/java/io/github/egonw/nanojava/manipulator/SubstanceManipulatorTest.java
+++ b/src/test/java/io/github/egonw/nanojava/manipulator/SubstanceManipulatorTest.java
@@ -16,30 +16,34 @@
*/
package io.github.egonw.nanojava.manipulator;
+import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Assert;
+import org.junit.jupiter.api.Test;
+
+import com.github.jqudt.onto.units.LengthUnit;
import io.github.egonw.nanojava.data.Material;
import io.github.egonw.nanojava.data.measurement.EndPoints;
import io.github.egonw.nanojava.data.measurement.ErrorlessMeasurementValue;
-import org.junit.Test;
-
-import com.github.jqudt.onto.units.LengthUnit;
public class SubstanceManipulatorTest {
@Test
public void testAlwaysReturnsLabelList() throws Exception {
Material nm = new Material("GRAPHENE");
- Assert.assertNotNull(SubstanceManipulator.getLabels(nm));
+ assertNotNull(SubstanceManipulator.getLabels(nm));
}
@Test
public void testChemicalCompisitionWhenEmpty() throws Exception {
Material nm = new Material("GRAPHENE");
- Assert.assertNull(SubstanceManipulator.getChemicalComposition(nm));
+ assertNull(SubstanceManipulator.getChemicalComposition(nm));
}
@Test
@@ -48,9 +52,9 @@ public void testLabels() throws Exception {
List labels = new ArrayList();
labels.add("NM1"); labels.add("CeO2-15");
SubstanceManipulator.setLabels(nm, labels);
- Assert.assertNotNull(SubstanceManipulator.getLabels(nm));
- Assert.assertEquals(2, SubstanceManipulator.getLabels(nm).size());
- Assert.assertTrue(SubstanceManipulator.getLabels(nm).contains("NM1"));
+ assertNotNull(SubstanceManipulator.getLabels(nm));
+ assertEquals(2, SubstanceManipulator.getLabels(nm).size());
+ assertTrue(SubstanceManipulator.getLabels(nm).contains("NM1"));
}
@Test
@@ -58,8 +62,8 @@ public void testMultipleSizes() throws Exception {
Material nm = new Material("GRAPHENE");
nm.addCharacterization(new ErrorlessMeasurementValue(EndPoints.DIAMETER_TEM, 20.0, LengthUnit.NM));
nm.addCharacterization(new ErrorlessMeasurementValue(EndPoints.DIAMETER_DLS, 55.0, LengthUnit.NM));
- Assert.assertNotNull(SubstanceManipulator.getCharacterizations(nm));
- Assert.assertEquals(2, SubstanceManipulator.getCharacterizations(nm).size());
+ assertNotNull(SubstanceManipulator.getCharacterizations(nm));
+ assertEquals(2, SubstanceManipulator.getCharacterizations(nm).size());
}
}