Skip to content

Commit 635f84f

Browse files
committed
metamorph-test/ (main): Fix Checkstyle violations.
1 parent b600d81 commit 635f84f

22 files changed

+138
-122
lines changed

metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestCase.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.metamorph.test;
1716

18-
import java.io.FileNotFoundException;
19-
import java.io.StringReader;
17+
package org.metafacture.metamorph.test;
2018

21-
import org.junit.runners.model.InitializationError;
22-
import org.junit.runners.model.Statement;
2319
import org.metafacture.commons.ResourceUtil;
2420
import org.metafacture.commons.XmlUtil;
2521
import org.metafacture.commons.reflection.ReflectionUtil;
@@ -30,20 +26,25 @@
3026
import org.metafacture.metamorph.test.reader.MultiFormatReader;
3127
import org.metafacture.metamorph.test.reader.Reader;
3228
import org.metafacture.metamorph.test.validators.StreamValidator;
29+
30+
import org.junit.runners.model.InitializationError;
31+
import org.junit.runners.model.Statement;
3332
import org.w3c.dom.Element;
3433
import org.w3c.dom.NodeList;
3534
import org.xml.sax.InputSource;
3635

36+
import java.io.FileNotFoundException;
37+
import java.io.StringReader;
38+
3739
/**
3840
* Runs a test defined in a Metamorph-Test definition.
3941
*
4042
* @author Christoph Böhme
4143
*
4244
*/
43-
final class MetamorphTestCase extends Statement {
45+
final class MetamorphTestCase extends Statement { // checkstyle-disable-line ClassDataAbstractionCoupling
4446

45-
private static final String NO_DATA_FOUND =
46-
"Please specify either element content or a src attribute";
47+
private static final String NO_DATA_FOUND = "Please specify either element content or a src attribute";
4748

4849
private static final String NAME_ATTR = "name";
4950
private static final String IGNORE_ATTR = "ignore";
@@ -77,20 +78,23 @@ public boolean isIgnore() {
7778
public void evaluate() throws InitializationError {
7879
final Reader inputReader = getReader(INPUT_TAG);
7980
@SuppressWarnings("unchecked")
80-
final StreamPipe<StreamReceiver>transformation = getTransformation();
81+
final StreamPipe<StreamReceiver> transformation = getTransformation();
8182
final EventList resultStream = new EventList();
8283

8384
if (transformation == null) {
8485
inputReader.setReceiver(resultStream);
85-
} else {
86+
}
87+
else {
8688
inputReader.setReceiver(transformation).setReceiver(resultStream);
8789
}
8890

8991
inputReader.process(getInputData());
9092
inputReader.closeStream();
9193

9294
final StreamValidator validator = new StreamValidator(resultStream.getEvents());
93-
validator.setErrorHandler(msg -> { throw new AssertionError(msg); });
95+
validator.setErrorHandler(msg -> {
96+
throw new AssertionError(msg);
97+
});
9498

9599
final Element result = (Element) config.getElementsByTagName(RESULT_TAG).item(0);
96100
validator.setStrictRecordOrder(Boolean.parseBoolean(
@@ -113,8 +117,7 @@ private Reader getReader(final String tag) {
113117
return new MultiFormatReader(mimeType);
114118
}
115119

116-
@SuppressWarnings("rawtypes")
117-
private StreamPipe getTransformation() throws InitializationError {
120+
private StreamPipe getTransformation() throws InitializationError { // checkstyle-disable-line ReturnCount
118121
final NodeList nodes = config.getElementsByTagName(TRANSFORMATION_TAG);
119122
if (nodes.getLength() == 0) {
120123
return null;
@@ -133,7 +136,8 @@ private StreamPipe getTransformation() throws InitializationError {
133136
}
134137
return new Metamorph(src);
135138

136-
} else if (MIME_JAVACLASS.equals(type)) {
139+
}
140+
else if (MIME_JAVACLASS.equals(type)) {
137141
if (src.isEmpty()) {
138142
throw new InitializationError(
139143
"class defining transformation not specified");
@@ -165,7 +169,8 @@ private java.io.Reader getDataFromSource(final String src)
165169
throws InitializationError {
166170
try {
167171
return ResourceUtil.getReader(src);
168-
} catch (final FileNotFoundException e) {
172+
}
173+
catch (final FileNotFoundException e) {
169174
throw new InitializationError("Could not find input file '" + src +
170175
"': " + e.getMessage());
171176
}

metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestLoader.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright 2013, 2014 Deutsche Nationalbibliothek
33
*
44
* Licensed under the Apache License, Version 2.0 the "License";
@@ -13,28 +13,27 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test;
1718

19+
import org.junit.runners.model.InitializationError;
20+
import org.w3c.dom.Document;
21+
import org.w3c.dom.Element;
22+
import org.w3c.dom.NodeList;
23+
import org.xml.sax.InputSource;
24+
import org.xml.sax.SAXException;
25+
1826
import java.io.IOException;
1927
import java.net.URL;
2028
import java.util.ArrayList;
2129
import java.util.List;
22-
2330
import javax.xml.XMLConstants;
2431
import javax.xml.parsers.DocumentBuilder;
2532
import javax.xml.parsers.DocumentBuilderFactory;
2633
import javax.xml.parsers.ParserConfigurationException;
2734
import javax.xml.validation.Schema;
2835
import javax.xml.validation.SchemaFactory;
2936

30-
import org.junit.runners.model.InitializationError;
31-
import org.w3c.dom.Document;
32-
import org.w3c.dom.Element;
33-
import org.w3c.dom.NodeList;
34-
import org.xml.sax.InputSource;
35-
import org.xml.sax.SAXException;
36-
37-
3837
/**
3938
* Utility methods for loading Metamorph-Test resources.
4039
*
@@ -81,17 +80,17 @@ private static List<MetamorphTestCase> load(final InputSource inputSource)
8180

8281
final List<MetamorphTestCase> metamorphTestCases = new ArrayList<>();
8382
final NodeList testCaseNodes = doc.getElementsByTagName(TEST_CASE_TAG);
84-
for(int i=0; i < testCaseNodes.getLength(); ++i) {
83+
for (int i = 0; i < testCaseNodes.getLength(); ++i) {
8584
final Element testCaseElement = (Element) testCaseNodes.item(i);
8685
metamorphTestCases.add(new MetamorphTestCase(testCaseElement));
8786
}
8887

8988
return metamorphTestCases;
9089

91-
} catch (final ParserConfigurationException|SAXException|IOException e) {
90+
}
91+
catch (final ParserConfigurationException | SAXException | IOException e) {
9292
throw new InitializationError(e);
9393
}
9494
}
9595

9696
}
97-

metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestRunner.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.metamorph.test;
1716

18-
import java.net.URL;
19-
import java.util.List;
17+
package org.metafacture.metamorph.test;
2018

2119
import org.junit.runner.Description;
2220
import org.junit.runner.notification.RunNotifier;
2321
import org.junit.runners.ParentRunner;
2422
import org.junit.runners.model.InitializationError;
2523

24+
import java.net.URL;
25+
import java.util.List;
26+
2627
/**
2728
* Executes test cases defined in a metamorph-test file.
2829
*
@@ -71,7 +72,8 @@ protected void runChild(final MetamorphTestCase child,
7172
final Description description = describeChild(child);
7273
if (child.isIgnore()) {
7374
notifier.fireTestIgnored(description);
74-
} else {
75+
}
76+
else {
7577
runLeaf(child, description, notifier);
7678
}
7779
}

metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestSuite.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test;
1718

19+
import org.junit.runner.Description;
20+
import org.junit.runner.Runner;
21+
import org.junit.runner.notification.RunNotifier;
22+
import org.junit.runners.ParentRunner;
23+
import org.junit.runners.model.InitializationError;
24+
1825
import java.lang.annotation.ElementType;
1926
import java.lang.annotation.Retention;
2027
import java.lang.annotation.RetentionPolicy;
2128
import java.lang.annotation.Target;
2229
import java.util.ArrayList;
2330
import java.util.List;
2431

25-
import org.junit.runner.Description;
26-
import org.junit.runner.Runner;
27-
import org.junit.runner.notification.RunNotifier;
28-
import org.junit.runners.ParentRunner;
29-
import org.junit.runners.model.InitializationError;
30-
3132
/**
3233
* Binds a list of Metamorph-Test resources to a class.
3334
*
@@ -45,18 +46,16 @@ public MetamorphTestSuite(final Class<?> suiteRoot)
4546
runners = loadDefinitions(suiteRoot);
4647
}
4748

48-
private static List<Runner> loadDefinitions(final Class<?> suiteRoot)
49-
throws InitializationError{
49+
private static List<Runner> loadDefinitions(final Class<?> suiteRoot) throws InitializationError {
5050
final List<Runner> runners = new ArrayList<>();
5151
for (final String testDef : getTestDefinitionNames(suiteRoot)) {
5252
runners.add(new MetamorphTestRunner(suiteRoot, testDef));
5353
}
5454
return runners;
5555
}
5656

57-
private static String[] getTestDefinitionNames(final Class<?> suiteRoot){
58-
final TestDefinitions testDefs =
59-
suiteRoot.getAnnotation(TestDefinitions.class);
57+
private static String[] getTestDefinitionNames(final Class<?> suiteRoot) {
58+
final TestDefinitions testDefs = suiteRoot.getAnnotation(TestDefinitions.class);
6059
if (testDefs == null) {
6160
// if no xmls are given assume an xml with the same name as the class:
6261
return new String[]{suiteRoot.getSimpleName() + ".xml"};

metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/CGXmlReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test.reader;
1718

1819
import org.metafacture.xml.CGXmlHandler;

metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/FormetaReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test.reader;
1718

1819
import org.metafacture.formeta.FormetaDecoder;

metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonLinesReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test.reader;
1718

1819
import org.metafacture.io.LineReader;

metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test.reader;
1718

1819
import org.metafacture.io.RecordReader;

metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MarcXmlReader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test.reader;
1718

1819
import org.metafacture.biblio.marc21.MarcXmlHandler;

metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MultiFormatReader.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.metamorph.test.reader;
1718

1819
import org.metafacture.framework.StreamReceiver;
1920

20-
2121
/**
2222
* Dynamically instantiated a reader for a specific data format. This module
2323
* allows to select a concrete reader only at runtime.
@@ -36,9 +36,8 @@ public MultiFormatReader(final String format) {
3636
}
3737

3838
public void setFormat(final String format) {
39-
if(!READER_FACTORY.containsKey(format)){
40-
throw new IllegalArgumentException("Format '" + format +
41-
"' not regognized");
39+
if (!READER_FACTORY.containsKey(format)) {
40+
throw new IllegalArgumentException("Format '" + format + "' not regognized");
4241
}
4342
currentReader = READER_FACTORY.newInstance(format);
4443
currentReader.setReceiver(downstreamReceiver);

0 commit comments

Comments
 (0)