Skip to content

Commit

Permalink
These methods don't need to be public, as noted by SonarCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Sep 11, 2022
1 parent 0436f60 commit 1793175
Show file tree
Hide file tree
Showing 1,058 changed files with 11,857 additions and 11,721 deletions.
Expand Up @@ -38,7 +38,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class AbbreviationsTest {
class AbbreviationsTest {

private static final SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());

Expand All @@ -47,7 +47,7 @@ static IAtomContainer smi(String smi) throws Exception {
}

@Test
public void potassiumCarbonate() throws Exception {
void potassiumCarbonate() throws Exception {
IAtomContainer mol = smi("[K+].[O-]C(=O)[O-].[K+]");
Abbreviations factory = new Abbreviations();
factory.add("[K+].[O-]C(=O)[O-].[K+] K2CO3");
Expand All @@ -59,7 +59,7 @@ public void potassiumCarbonate() throws Exception {
}

@Test
public void phenyl() throws Exception {
void phenyl() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("CCCCCCC(c1ccccc1)(c1ccccc1)c1ccccc1");
factory.add("*c1ccccc1 Ph");
Expand All @@ -77,7 +77,7 @@ public void phenyl() throws Exception {
}

@Test
public void phenylShouldNotMatchBenzene() throws Exception {
void phenylShouldNotMatchBenzene() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("c1ccccc1");
factory.add("*c1ccccc1 Ph");
Expand All @@ -86,7 +86,7 @@ public void phenylShouldNotMatchBenzene() throws Exception {
}

@Test
public void TFASaltDisconnected() throws Exception {
void TFASaltDisconnected() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("c1ccccc1c1ccccc1.FC(F)(F)C(=O)O");
factory.add("*C(F)(F)F CF3");
Expand All @@ -98,7 +98,7 @@ public void TFASaltDisconnected() throws Exception {
}

@Test
public void TFASaltConnected() throws Exception {
void TFASaltConnected() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("FC(F)(F)C(=O)O");
factory.add("*C(F)(F)F CF3");
Expand All @@ -115,7 +115,7 @@ public void TFASaltConnected() throws Exception {
}

@Test
public void DcmAndTfa() throws Exception {
void DcmAndTfa() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("ClCCl.FC(F)(F)C(=O)O");
factory.add("ClCCl DCM");
Expand All @@ -127,7 +127,7 @@ public void DcmAndTfa() throws Exception {
}

@Test
public void DcmAndTfaNoSingleFrag() throws Exception {
void DcmAndTfaNoSingleFrag() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("ClCCl.FC(F)(F)C(=O)O");
factory.add("ClCCl DCM");
Expand All @@ -139,15 +139,15 @@ public void DcmAndTfaNoSingleFrag() throws Exception {
}

@Test
public void avoidOverZealousAbbreviations() throws Exception {
void avoidOverZealousAbbreviations() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("Clc1ccccc1");
factory.add("*c1ccccc1 Ph");
assertThat(factory.apply(mol), is(0));
}

@Test
public void phenylShouldNotMatchC4H6() throws Exception {
void phenylShouldNotMatchC4H6() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("Oc1ccc(O)cc1");
factory.add("*c1ccccc1 Ph");
Expand All @@ -156,7 +156,7 @@ public void phenylShouldNotMatchC4H6() throws Exception {
}

@Test
public void phenylShouldAbbreviateExplicitHydrogens() throws Exception {
void phenylShouldAbbreviateExplicitHydrogens() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("CCCCc1ccc([H])cc1");
factory.add("*c1ccccc1 Ph");
Expand All @@ -169,7 +169,7 @@ public void phenylShouldAbbreviateExplicitHydrogens() throws Exception {

// some SMARTS foo here :-)
@Test
public void phenylShouldMatchKekuleForm() throws Exception {
void phenylShouldMatchKekuleForm() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("CCCCC1=CC=CC=C1");
factory.add("*c1ccccc1 Ph");
Expand All @@ -182,7 +182,7 @@ public void phenylShouldMatchKekuleForm() throws Exception {

// SMARTS foo not that good
@Test
public void nitroGroups() throws Exception {
void nitroGroups() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("O=N(=O)CCCC[N+]([O-])=O");
factory.add("*N(=O)(=O) NO2");
Expand All @@ -198,7 +198,7 @@ public void nitroGroups() throws Exception {
}

@Test
public void abbreviationsHavePriority() throws Exception {
void abbreviationsHavePriority() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("c1ccccc1CCC");
factory.add("*CCC Pr");
Expand All @@ -209,7 +209,7 @@ public void abbreviationsHavePriority() throws Exception {
}

@Test
public void dontOverwriteExistingSgroups() throws Exception {
void dontOverwriteExistingSgroups() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*CCC Bu");
IAtomContainer mol = smi("c1ccccc1CCC");
Expand All @@ -224,7 +224,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.size(), is(0));
}

@Test public void NHBocFromHeteroCollapse() throws Exception {
@Test
void NHBocFromHeteroCollapse() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*C(=O)OC(C)(C)C Boc");
IAtomContainer mol = smi("c1ccccc1NC(=O)OC(C)(C)C");
Expand All @@ -235,7 +236,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getAtoms().size(), is(8));
}

@Test public void NHBocFromHeteroCollapseExplicitH() throws Exception {
@Test
void NHBocFromHeteroCollapseExplicitH() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*C(=O)OC(C)(C)C Boc");
IAtomContainer mol = smi("c1ccccc1N([H])C(=O)OC(C)(C)C");
Expand All @@ -246,7 +248,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getAtoms().size(), is(9));
}

@Test public void NBocClFromHeteroCollapseExplicit() throws Exception {
@Test
void NBocClFromHeteroCollapseExplicit() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*C(=O)OC(C)(C)C Boc");
IAtomContainer mol = smi("c1ccccc1N(Cl)C(=O)OC(C)(C)C");
Expand All @@ -257,7 +260,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getAtoms().size(), is(9));
}

@Test public void NBoc2FromHeteroCollapse() throws Exception {
@Test
void NBoc2FromHeteroCollapse() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*C(=O)OC(C)(C)C Boc");
IAtomContainer mol = smi("c1cc2ccccc2cc1N(C(=O)OC(C)(C)C)C(=O)OC(C)(C)C");
Expand All @@ -268,7 +272,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getAtoms().size(), is(15));
}

@Test public void iPrFromHeteroCollapse() throws Exception {
@Test
void iPrFromHeteroCollapse() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*C(C)C iPr");
IAtomContainer mol = smi("[CH3:27][CH:19]([CH3:28])[C:20]1=[N:26][C:23](=[CH:22][S:21]1)[C:24](=[O:25])O");
Expand All @@ -279,7 +284,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getAtoms().size(), is(3));
}

@Test public void NBocFromHeteroCollapseExplicitH() throws Exception {
@Test
void NBocFromHeteroCollapseExplicitH() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*C(=O)OC(C)(C)C Boc");
IAtomContainer mol = smi("c1cc2ccccc2ccn1C(=O)OC(C)(C)C");
Expand All @@ -290,7 +296,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getAtoms().size(), is(8));
}

@Test public void SO3minusFromHeteroCollapseNone() throws Exception {
@Test
void SO3minusFromHeteroCollapseNone() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("*S(=O)(=O)[O-] SO3-");
IAtomContainer mol = smi("c1ccccc1N(S(=O)(=O)[O-])S(=O)(=O)[O-]");
Expand All @@ -300,7 +307,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(1).getSubscript(), is("SO3-"));
}

@Test public void hclSaltOfEdci() throws Exception {
@Test
void hclSaltOfEdci() throws Exception {
Abbreviations factory = new Abbreviations();
factory.add("CCN=C=NCCCN(C)C EDCI");
factory.setContractToSingleLabel(true);
Expand All @@ -310,23 +318,26 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getSubscript(), is("EDCI·HCl"));
}

@Test public void SnCl2() throws Exception {
@Test
void SnCl2() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("Cl[Sn]Cl");
List<Sgroup> sgroups = factory.generate(mol);
assertThat(sgroups.size(), is(1));
assertThat(sgroups.get(0).getSubscript(), is("SnCl2"));
}

@Test public void HOOH() throws Exception {
@Test
void HOOH() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("OO");
List<Sgroup> sgroups = factory.generate(mol);
assertThat(sgroups.size(), is(1));
assertThat(sgroups.get(0).getSubscript(), is("HOOH"));
}

@Test public void multipleDisconnectedAbbreviations() throws Exception {
@Test
void multipleDisconnectedAbbreviations() throws Exception {
String smi = "ClCCl.Cl[Pd]Cl.[Fe+2].c1ccc(P([c-]2cccc2)c2ccccc2)cc1.c1ccc(P([c-]2cccc2)c2ccccc2)cc1";
Abbreviations factory = new Abbreviations();
factory.add("ClCCl DCM");
Expand All @@ -338,7 +349,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
assertThat(sgroups.get(0).getSubscript(), is("Pd(dppf)Cl2·DCM"));
}

@Test public void multipleDisconnectedAbbreviations2() throws Exception {
@Test
void multipleDisconnectedAbbreviations2() throws Exception {
String smi = "ClCCl.Cl[Pd]Cl.[Fe+2].c1ccc(P([c-]2cccc2)c2ccccc2)cc1.c1ccc(P([c-]2cccc2)c2ccccc2)cc1";
Abbreviations factory = new Abbreviations();
factory.add("Cl[Pd]Cl.[Fe+2].c1ccc(P([c-]2cccc2)c2ccccc2)cc1.c1ccc(P([c-]2cccc2)c2ccccc2)cc1 Pd(dppf)Cl2");
Expand All @@ -351,7 +363,8 @@ public void dontOverwriteExistingSgroups() throws Exception {
}

// Don't generate NiPr
@Test public void avoidAmbiguity() throws Exception {
@Test
void avoidAmbiguity() throws Exception {
String smi = "C1CCCCC1=NC(C)C";
Abbreviations factory = new Abbreviations();
factory.add("*C(C)C iPr");
Expand All @@ -362,7 +375,7 @@ public void dontOverwriteExistingSgroups() throws Exception {
}

@Test
public void loadFromFile() throws Exception {
void loadFromFile() throws Exception {
Abbreviations factory = new Abbreviations();
assertThat(factory.loadFromFile("obabel_superatoms.smi"), is(27));
assertThat(factory.loadFromFile("/org/openscience/cdk/depict/obabel_superatoms.smi"), is(27));
Expand Down
Expand Up @@ -30,10 +30,10 @@
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.smiles.SmilesParser;

public class DepictionTest {
class DepictionTest {

@Test
public void depictAsPs() throws CDKException {
void depictAsPs() throws CDKException {
DepictionGenerator dg = new DepictionGenerator();
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer ac = sp.parseSmiles("[nH]1cccc1");
Expand All @@ -45,7 +45,7 @@ public void depictAsPs() throws CDKException {
}

@Test
public void depictAsEps() throws CDKException {
void depictAsEps() throws CDKException {
DepictionGenerator dg = new DepictionGenerator();
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer ac = sp.parseSmiles("[nH]1cccc1");
Expand All @@ -57,7 +57,7 @@ public void depictAsEps() throws CDKException {
}

@Test
public void depictAsEps2() throws CDKException {
void depictAsEps2() throws CDKException {
DepictionGenerator dg = new DepictionGenerator();
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer ac = sp.parseSmiles("C1CCCCC1CCCCC");
Expand All @@ -69,7 +69,7 @@ public void depictAsEps2() throws CDKException {
}

@Test
public void depictAsSvg() throws CDKException {
void depictAsSvg() throws CDKException {
DepictionGenerator dg = new DepictionGenerator();
SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer ac = sp.parseSmiles("[nH]1cccc1");
Expand Down
Expand Up @@ -38,10 +38,10 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class SvgDrawVisitorTest {
class SvgDrawVisitorTest {

@Test
public void empty() {
void empty() {
String empty = new SvgDrawVisitor(50, 50, Depiction.UNITS_MM).toString();
assertThat(empty, is("<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
Expand All @@ -51,7 +51,7 @@ public void empty() {
}

@Test
public void markedElement() {
void markedElement() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(50, 50, Depiction.UNITS_MM);
visitor.visit(MarkedElement.markup(new LineElement(0, 0, 1, 1, 0.5, Color.RED),
"test-class"));
Expand All @@ -66,7 +66,7 @@ public void markedElement() {
}

@Test
public void translatedLine() {
void translatedLine() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(50, 50, Depiction.UNITS_MM);
visitor.visit(new LineElement(0, 0, 1, 1, 0.5, Color.RED));
visitor.setTransform(AffineTransform.getTranslateInstance(10, 10));
Expand All @@ -83,7 +83,7 @@ public void translatedLine() {
}

@Test
public void scaledStroke() {
void scaledStroke() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(50, 50, Depiction.UNITS_MM);
visitor.visit(new LineElement(0, 0, 1, 1, 0.5, Color.RED));
visitor.setTransform(AffineTransform.getScaleInstance(2, 2));
Expand All @@ -100,7 +100,7 @@ public void scaledStroke() {
}

@Test
public void filledPath() {
void filledPath() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(50, 50, Depiction.UNITS_MM);
visitor.visit(GeneralPath.shapeOf(new RoundRectangle2D.Double(0,0,10,10,2,2), Color.BLUE));
assertThat(visitor.toString(), is("<?xml version='1.0' encoding='UTF-8'?>\n"
Expand All @@ -114,7 +114,7 @@ public void filledPath() {
}

@Test
public void transformedPath() {
void transformedPath() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(50, 50, Depiction.UNITS_MM);
visitor.setTransform(AffineTransform.getTranslateInstance(15, 15));
visitor.visit(GeneralPath.shapeOf(new RoundRectangle2D.Double(0, 0, 10, 10, 2, 2), Color.BLUE));
Expand All @@ -129,7 +129,7 @@ public void transformedPath() {
}

@Test
public void textElements() {
void textElements() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(100, 100, Depiction.UNITS_MM);
visitor.visit(new TextElement(50, 50, "PNG < EPS < SVG", Color.RED));
assertThat(visitor.toString(), is("<?xml version='1.0' encoding='UTF-8'?>\n"
Expand All @@ -143,7 +143,7 @@ public void textElements() {
}

@Test
public void rectElements() {
void rectElements() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(100, 100, Depiction.UNITS_MM);
visitor.visit(new RectangleElement(0,0,100,100, Color.WHITE));
assertThat(visitor.toString(), is("<?xml version='1.0' encoding='UTF-8'?>\n"
Expand All @@ -157,7 +157,7 @@ public void rectElements() {
}

@Test
public void testTransparencyLocaleEncoding() {
void testTransparencyLocaleEncoding() {
final SvgDrawVisitor visitor = new SvgDrawVisitor(50, 50, Depiction.UNITS_MM);
visitor.setTransform(AffineTransform.getTranslateInstance(15, 15));
visitor.visit(GeneralPath.shapeOf(new RoundRectangle2D.Double(0, 0, 10, 10, 2, 2), new Color(255,0,0,126)));
Expand Down

0 comments on commit 1793175

Please sign in to comment.