24
24
25
25
import org .junit .Assert ;
26
26
import org .junit .Test ;
27
+ import org .mockito .Mockito ;
27
28
import org .openscience .cdk .CDKTestCase ;
29
+ import org .openscience .cdk .interfaces .IAtomContainer ;
30
+ import org .openscience .cdk .interfaces .IChemFile ;
31
+ import org .openscience .cdk .interfaces .IChemModel ;
32
+ import org .openscience .cdk .interfaces .IChemObject ;
33
+ import org .openscience .cdk .interfaces .IReaction ;
28
34
import org .openscience .cdk .io .formats .IResourceFormat ;
29
35
import org .openscience .cdk .io .listener .IChemObjectIOListener ;
30
36
import org .openscience .cdk .io .setting .IOSetting ;
37
+ import org .openscience .cdk .isomorphism .matchers .IRGroupQuery ;
38
+
39
+ import static org .mockito .Mockito .mock ;
31
40
32
41
/**
33
42
* TestCase for CDK IO classes.
@@ -53,54 +62,29 @@ public void testGetFormat() {
53
62
Assert .assertNotNull ("The IChemObjectIO.getFormat method returned null." , format );
54
63
}
55
64
56
- /*
57
- private static IChemObject[] acceptableNNChemObjects = {new ChemFile(), new ChemModel(), new AtomContainer(),
58
- new Reaction() };
59
-
60
- @Test
61
- public void testAcceptsAtLeastOneNonotifyObject() {
62
- boolean oneAccepted = false;
63
- for (IChemObject object : acceptableNNChemObjects) {
64
- if (chemObjectIO.accepts(object.getClass())) {
65
- oneAccepted = true;
66
- }
67
- }
68
- Assert.assertTrue(
69
- "At least one of the following IChemObect's should be accepted: IChemFile, IChemModel, IAtomContainer, IReaction",
70
- oneAccepted);
71
- }
72
-
73
- private static IChemObject[] acceptableDebugChemObjects = {new DebugChemFile(), new DebugChemModel(),
74
- new DebugAtomContainer(), new DebugReaction() };
75
-
76
- @Test
77
- public void testAcceptsAtLeastOneDebugObject() {
78
- boolean oneAccepted = false;
79
- for (IChemObject object : acceptableDebugChemObjects) {
80
- if (chemObjectIO.accepts(object.getClass())) {
81
- oneAccepted = true;
82
- }
83
- }
84
- Assert.assertTrue(
85
- "At least one of the following IChemObect's should be accepted: IChemFile, IChemModel, IAtomContainer, IReaction",
86
- oneAccepted);
87
- }
88
-
89
- // static objects, shared between tests - difficult to locate bugs.
90
- @Deprecated
91
- protected static IChemObject[] acceptableChemObjects = {new ChemFile(), new ChemModel(), new AtomContainer(),
92
- new Reaction(), new RGroupQuery(DefaultChemObjectBuilder.getInstance())};
65
+ // FIXME add IRgroupQuery.class
66
+ protected static Class <?>[] acceptableChemObjectClasses = {
67
+ IChemFile .class ,
68
+ IChemModel .class ,
69
+ IAtomContainer .class ,
70
+ IReaction .class ,
71
+ IRGroupQuery .class };
93
72
94
73
protected static IChemObject [] acceptableChemObjects () {
95
- return new IChemObject[]{new ChemFile(), new ChemModel(), new AtomContainer(), new Reaction(),
96
- new RGroupQuery(DefaultChemObjectBuilder.getInstance())};
74
+ return new IChemObject []{
75
+ mock (IChemFile .class ),
76
+ mock (IChemModel .class ),
77
+ mock (IAtomContainer .class ),
78
+ mock (IReaction .class ),
79
+ mock (IRGroupQuery .class )
80
+ };
97
81
}
98
82
99
83
@ Test
100
84
public void testAcceptsAtLeastOneChemObject () {
101
85
boolean oneAccepted = false ;
102
- for (IChemObject object : acceptableChemObjects) {
103
- if (chemObjectIO.accepts(object .getClass())) {
86
+ for (IChemObject obj : acceptableChemObjects () ) {
87
+ if (chemObjectIO .accepts (obj .getClass ())) {
104
88
oneAccepted = true ;
105
89
}
106
90
}
@@ -109,25 +93,20 @@ public void testAcceptsAtLeastOneChemObject() {
109
93
oneAccepted );
110
94
}
111
95
112
- @SuppressWarnings("rawtypes")
113
- protected static Class[] acceptableChemObjectClasses = {IChemFile.class, IChemModel.class, IAtomContainer.class,
114
- IReaction.class, IRGroupQuery.class };
115
-
116
- // @cdk.bug 3553780
117
- @SuppressWarnings("unchecked")
96
+ /** @cdk.bug 3553780 */
118
97
@ Test
98
+ @ SuppressWarnings ("unchecked" )
119
99
public void testAcceptsAtLeastOneChemObjectClass () {
120
100
boolean oneAccepted = false ;
121
- for (Class<? extends IChemObject> clazz : acceptableChemObjectClasses) {
122
- if (chemObjectIO.accepts(clazz )) {
101
+ for (Class <?> cls : acceptableChemObjectClasses ) {
102
+ if (chemObjectIO .accepts (( Class <? extends IChemObject >) cls )) {
123
103
oneAccepted = true ;
124
104
}
125
105
}
126
106
Assert .assertTrue (
127
107
"At least one of the following IChemObect's should be accepted: IChemFile, IChemModel, IAtomContainer, IReaction, IRGroupQuery" ,
128
108
oneAccepted );
129
109
}
130
- */
131
110
132
111
@ Test
133
112
public void testClose () throws Exception {
0 commit comments