Skip to content

Commit e14cd05

Browse files
Heng CuiHeng Cui
authored andcommitted
spotless apply
1 parent 00a76b8 commit e14cd05

3 files changed

Lines changed: 315 additions & 296 deletions

File tree

candyfloss/src/test/java/com/swisscom/daisy/cosmos/candyfloss/AbstractDeploymentTest.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import com.swisscom.daisy.cosmos.candyfloss.config.JsonKStreamApplicationConfig;
1212
import com.swisscom.daisy.cosmos.candyfloss.config.PipelineStepConfig;
1313
import com.swisscom.daisy.cosmos.candyfloss.config.exceptions.InvalidConfigurations;
14-
import com.swisscom.daisy.cosmos.candyfloss.testutils.OutputUpdaterUtils;
1514
import com.swisscom.daisy.cosmos.candyfloss.testutils.JsonUtil;
15+
import com.swisscom.daisy.cosmos.candyfloss.testutils.OutputUpdaterUtils;
1616
import com.swisscom.daisy.cosmos.candyfloss.transformations.match.exceptions.InvalidMatchConfiguration;
1717
import com.typesafe.config.Config;
1818
import com.typesafe.config.ConfigFactory;
@@ -42,7 +42,8 @@ abstract class AbstractDeploymentTest {
4242
private final Logger logger = LoggerFactory.getLogger(AbstractDeploymentTest.class);
4343
private static final String UPDATE_DEPLOYMENT_RESOURCE = "candyfloss.updateDeploymentResource";
4444
private static final String COMMENT_TRAILING_ANCHOR = "__COMMENT_TRAILING__";
45-
private static final Pattern FIELD_NAME_PATTERN = Pattern.compile("^\"((?:\\\\.|[^\"\\\\])+)\"\\s*:");
45+
private static final Pattern FIELD_NAME_PATTERN =
46+
Pattern.compile("^\"((?:\\\\.|[^\"\\\\])+)\"\\s*:");
4647
protected final ObjectMapper objectMapper = new ObjectMapper(factory);
4748
protected static final String DISCARD_TEST = "discard";
4849
protected JsonKStreamApplicationConfig appConf;
@@ -96,7 +97,8 @@ protected void checkOutput(TestOutputTopic<String, String> topic, Path expectedO
9697
return;
9798
}
9899

99-
final Optional<List<Map<String, Object>>> expectedOutput = getExpectedOutput(expectedOutputPath);
100+
final Optional<List<Map<String, Object>>> expectedOutput =
101+
getExpectedOutput(expectedOutputPath);
100102
if (expectedOutput.isPresent()) {
101103
var expected = expectedOutput.get();
102104
assertEquals(
@@ -122,17 +124,17 @@ protected void checkOutput(TestOutputTopic<String, String> topic, Path expectedO
122124

123125
// only update output files if it originally exists and flag is set
124126
protected boolean shouldUpdateDeployment(Path expectedOutputPath) {
125-
return Boolean.parseBoolean(System.getProperty(UPDATE_DEPLOYMENT_RESOURCE, "false")) &&
126-
Files.exists(expectedOutputPath);
127+
return Boolean.parseBoolean(System.getProperty(UPDATE_DEPLOYMENT_RESOURCE, "false"))
128+
&& Files.exists(expectedOutputPath);
127129
}
128130

129-
private void writeExpectedOutput(Path expectedOutputPath,
130-
List<KeyValue<String, String>> returned) throws IOException {
131+
private void writeExpectedOutput(Path expectedOutputPath, List<KeyValue<String, String>> returned)
132+
throws IOException {
131133
JsonNode currentOutputTree = null;
132134
String originalContent = "";
133135
if (Files.exists(expectedOutputPath)) {
134-
originalContent = Files.readString(expectedOutputPath);
135-
currentOutputTree = objectMapper.readTree(originalContent);
136+
originalContent = Files.readString(expectedOutputPath);
137+
currentOutputTree = objectMapper.readTree(originalContent);
136138
}
137139

138140
JsonNode outputToWrite;
@@ -152,7 +154,7 @@ private void writeExpectedOutput(Path expectedOutputPath,
152154
}
153155

154156
OutputUpdaterUtils.writeExpectedOutput(
155-
expectedOutputPath, originalContent, currentOutputTree, outputToWrite, objectMapper);
157+
expectedOutputPath, originalContent, currentOutputTree, outputToWrite, objectMapper);
156158
}
157159

158160
/*** For a given path, extract all files that their name ends with an `ending`, used for automatic test files discovery.*/
@@ -166,7 +168,8 @@ private Map<Integer, Path> extractFiles(Path path, String ending) throws IOExcep
166168
}
167169

168170
/*** Read the expected JSON output and convert it to List of JSON objects, for easier compare during testing */
169-
protected Optional<List<Map<String, Object>>> getExpectedOutput(Path resourcePath) throws IOException {
171+
protected Optional<List<Map<String, Object>>> getExpectedOutput(Path resourcePath)
172+
throws IOException {
170173
if (!Files.exists(resourcePath)) {
171174
return Optional.empty();
172175
}

candyfloss/src/test/java/com/swisscom/daisy/cosmos/candyfloss/DeploymentTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ protected static Stream<Arguments> providerForYangModels(String profile)
7777
}
7878

7979
/**
80-
* Traverses up the directory tree from the compiled class location (e.g. build/resources/test/...)
81-
* to local "src/test/resources" directory for physical file read/write operations.
80+
* Traverses up the directory tree from the compiled class location (e.g.
81+
* build/resources/test/...) to local "src/test/resources" directory for physical file read/write
82+
* operations.
8283
*/
8384
private static Path resolveTestResourcesPath() throws IOException, URISyntaxException {
8485
Path location =

0 commit comments

Comments
 (0)