Skip to content

Commit 491305d

Browse files
authored
Formatting Test Packages Coding style (#653)
1 parent 3b6d40f commit 491305d

File tree

155 files changed

+2043
-1664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+2043
-1664
lines changed

src/test/java/com/mageddo/circuitbreaker/failsafe/CircuitStatusRefreshTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.mageddo.circuitbreaker.failsafe;
22

33
import com.mageddo.commons.concurrent.Threads;
4+
45
import org.junit.jupiter.api.Test;
6+
57
import testing.templates.solver.remote.FailSafeCircuitBreakerTemplates;
68

79
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -57,7 +59,7 @@ void closedStateWillNotBeAffected() {
5759
}
5860

5961
@Test
60-
void mustIgnoreNulls(){
62+
void mustIgnoreNulls() {
6163
final var refreshed = CircuitStatusRefresh.refresh(null);
6264
assertFalse(refreshed);
6365
}

src/test/java/com/mageddo/commons/exec/CommandLinesTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ class CommandLinesTest {
1010

1111

1212
@Test
13-
void mustValidateWhenExitsWithErrorCode(){
13+
void mustValidateWhenExitsWithErrorCode() {
1414

1515
final var result = CommandLines.exec(
16-
new CommandLine("sh")
17-
.addArgument("-c")
18-
.addArgument("exit 3", false)
16+
new CommandLine("sh")
17+
.addArgument("-c")
18+
.addArgument("exit 3", false)
1919
);
2020

2121
final var ex = assertThrows(ExecutionValidationFailedException.class, result::checkExecution);
@@ -25,7 +25,7 @@ void mustValidateWhenExitsWithErrorCode(){
2525
}
2626

2727
@Test
28-
void mustExecuteCommand(){
28+
void mustExecuteCommand() {
2929

3030
final var result = CommandLines.exec("echo %s", "hey");
3131

@@ -37,20 +37,20 @@ void mustExecuteCommand(){
3737
void mustExecuteAndPrintOutputConcurrently() {
3838

3939
final var result = CommandLines.exec(
40-
new CommandLine("sh")
41-
.addArgument("-c")
42-
.addArgument("echo hi && sleep 0.2 && echo hi2", false),
43-
new NopResultHandler()
40+
new CommandLine("sh")
41+
.addArgument("-c")
42+
.addArgument("echo hi && sleep 0.2 && echo hi2", false),
43+
new NopResultHandler()
4444
);
4545

4646
result.printOutToLogsInBackground();
4747

4848
result.waitProcessToFinish();
4949

5050
final var expectedOut = """
51-
hi
52-
hi2
53-
""";
51+
hi
52+
hi2
53+
""";
5454
assertEquals(expectedOut, result.getOutAsString());
5555
}
5656
}

src/test/java/com/mageddo/commons/exec/DelegateOutputStreamTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.mageddo.commons.exec;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import java.io.ByteArrayOutputStream;
64
import java.io.IOException;
75

6+
import org.junit.jupiter.api.Test;
7+
88
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
99

1010
class DelegateOutputStreamTest {

src/test/java/com/mageddo/commons/exec/PipedStreamTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.mageddo.commons.exec;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import java.io.ByteArrayOutputStream;
64
import java.io.IOException;
75

6+
import org.junit.jupiter.api.Test;
7+
88
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
99

1010
class PipedStreamTest {
@@ -22,6 +22,8 @@ void mustWriteToOutAndBeAbleToReadWhatIsBeingWritten() throws IOException {
2222
// assert
2323
final var bout = (ByteArrayOutputStream) stream.getOriginalOut();
2424
assertArrayEquals(bytes, bout.toByteArray());
25-
assertArrayEquals(bytes, stream.getPipedIn().readAllBytes());
25+
assertArrayEquals(bytes, stream.getPipedIn()
26+
.readAllBytes()
27+
);
2628
}
2729
}

src/test/java/com/mageddo/dns/HostnameTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
package com.mageddo.dns;
22

33
import org.junit.jupiter.api.Test;
4+
45
import testing.templates.HostnameTemplates;
56

6-
import static org.junit.jupiter.api.Assertions.*;
7+
import static org.junit.jupiter.api.Assertions.assertFalse;
8+
import static org.junit.jupiter.api.Assertions.assertTrue;
79

810
class HostnameTest {
911

1012
@Test
11-
void mustEndsWith(){
13+
void mustEndsWith() {
1214
final var hostname = Hostname.of(HostnameTemplates.NGINX_COM_BR);
1315
assertTrue(hostname.endsWith(".com.br"));
1416
}
1517

1618
@Test
17-
void mustNotEndsWith(){
19+
void mustNotEndsWith() {
1820
final var hostname = Hostname.of(HostnameTemplates.NGINX_COM_BR);
1921
assertFalse(hostname.endsWith(".com"));
2022
}

src/test/java/com/mageddo/dnsproxyserver/AppCompTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ void mustCreateTmpDirIfNotExists() {
5757
// arrange
5858
final var args = new String[]{"--create-tmp-dir"};
5959
this.setupStub(args);
60-
doNothing().when(this.app).startContext();
60+
doNothing().when(this.app)
61+
.startContext();
6162

6263
// act
6364
this.app.start();
@@ -76,12 +77,12 @@ void mustHandleFatalErrors() {
7677
this.setupStub(args);
7778

7879
doThrow(new IllegalAccessError("mocked fatal error"))
79-
.when(this.app)
80-
.checkHiddenCommands()
80+
.when(this.app)
81+
.checkHiddenCommands()
8182
;
8283
doNothing()
83-
.when(this.app)
84-
.exitWithError(anyInt())
84+
.when(this.app)
85+
.exitWithError(anyInt())
8586
;
8687

8788
// act
@@ -94,8 +95,8 @@ void mustHandleFatalErrors() {
9495
RuntimeException mockExitMethod() {
9596
final var expectedException = new App.SystemExitException("testing");
9697
doThrow(expectedException)
97-
.when(this.app)
98-
.exitGracefully()
98+
.when(this.app)
99+
.exitGracefully()
99100
;
100101
return expectedException;
101102
}

src/test/java/com/mageddo/dnsproxyserver/AppIntTest.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.mageddo.dnsproxyserver;
22

3+
import java.nio.file.Path;
4+
import java.time.Duration;
5+
import java.util.Arrays;
6+
import java.util.concurrent.ExecutorService;
7+
38
import com.mageddo.commons.concurrent.Threads;
49
import com.mageddo.commons.exec.ProcessesWatchDog;
510
import com.mageddo.dns.utils.Messages;
@@ -13,21 +18,18 @@
1318
import com.mageddo.dnsproxyserver.utils.Ips;
1419
import com.mageddo.net.IpAddr;
1520
import com.mageddo.utils.Executors;
16-
import lombok.SneakyThrows;
17-
import lombok.Value;
18-
import lombok.extern.slf4j.Slf4j;
21+
1922
import org.junit.jupiter.api.AfterAll;
2023
import org.junit.jupiter.api.BeforeEach;
2124
import org.junit.jupiter.api.Test;
2225
import org.xbill.DNS.Message;
26+
27+
import lombok.SneakyThrows;
28+
import lombok.Value;
29+
import lombok.extern.slf4j.Slf4j;
2330
import testing.templates.ConfigFlagArgsTemplates;
2431
import testing.templates.ConfigJsonFileTemplates;
2532

26-
import java.nio.file.Path;
27-
import java.time.Duration;
28-
import java.util.Arrays;
29-
import java.util.concurrent.ExecutorService;
30-
3133
import static org.junit.jupiter.api.Assertions.assertEquals;
3234
import static org.junit.jupiter.api.Assertions.assertTrue;
3335

@@ -43,7 +45,8 @@ void beforeEach() {
4345
@AfterAll
4446
static void afterAll() {
4547
Starter.setMustStartFlagActive(false);
46-
ProcessesWatchDog.instance().killAllProcesses();
48+
ProcessesWatchDog.instance()
49+
.killAllProcesses();
4750
}
4851

4952
@Test
@@ -88,11 +91,15 @@ void mustQueryRemoteSolverPassingThroughAllModulesAndGetSuccess() {
8891

8992
private static App buildClientAppAndWait(ExecutorService executor, Integer serverPort) {
9093
final var remoteAddr = IpAddr.of("127.0.0.1", serverPort);
91-
return buildAppAndWait(executor, ConfigFlagArgsTemplates.withRandomPortsAndNotAsDefaultDnsUsingRemote(remoteAddr));
94+
return buildAppAndWait(executor,
95+
ConfigFlagArgsTemplates.withRandomPortsAndNotAsDefaultDnsUsingRemote(remoteAddr)
96+
);
9297
}
9398

9499
private static Result buildAndStartServerApp(String hostToQuery) {
95-
final var configFile = ConfigJsonFileTemplates.withRandomPortsAndNotAsDefaultDnsAndCustomLocalDBEntry(hostToQuery);
100+
final var configFile =
101+
ConfigJsonFileTemplates.withRandomPortsAndNotAsDefaultDnsAndCustomLocalDBEntry(
102+
hostToQuery);
96103
final var instance = Sandbox.runFromGradleTests(configFile);
97104
return Result.of(configFile, instance);
98105
}

src/test/java/com/mageddo/dnsproxyserver/AppSettingsTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package com.mageddo.dnsproxyserver;
22

33
import com.mageddo.dnsproxyserver.application.LogSettings;
4-
import testing.templates.ConfigTemplates;
54
import com.mageddo.logback.LogbackUtils;
5+
66
import org.junit.jupiter.api.Test;
77

8+
import testing.templates.ConfigTemplates;
9+
810
import static org.junit.jupiter.api.Assertions.assertEquals;
911

1012
class AppSettingsTest {
1113
@Test
12-
void mustLogLevelInSl4jConversion(){
14+
void mustLogLevelInSl4jConversion() {
1315
// arrange
1416
final var config = ConfigTemplates.defaultWithoutId();
1517

src/test/java/com/mageddo/dnsproxyserver/config/ConfigsTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ void mustGenerateEnvHostnameIdWhenIsNull() {
1818
// act
1919
final var env = EnvTemplates.buildWithoutId();
2020
final var firstEntry = env
21-
.getEntries()
22-
.stream()
23-
.findFirst()
24-
.get();
21+
.getEntries()
22+
.stream()
23+
.findFirst()
24+
.get();
2525

2626
// assert
2727
assertNotNull(firstEntry.getId());
2828
final var currentNanoTime = System.nanoTime();
2929
assertTrue(
30-
firstEntry.getId() < currentNanoTime,
31-
String.format("id=%s, currentTimeInMillis=%s", firstEntry.getId(), currentNanoTime)
30+
firstEntry.getId() < currentNanoTime,
31+
String.format("id=%s, currentTimeInMillis=%s", firstEntry.getId(), currentNanoTime)
3232
);
3333
}
3434

3535
@Test
36-
void mustCreateDefaultConfigFileOnRandomPathWhenTesting(){
36+
void mustCreateDefaultConfigFileOnRandomPathWhenTesting() {
3737

3838
final var config = Configs.getInstance();
3939

src/test/java/com/mageddo/dnsproxyserver/config/application/ConfigFileFinderServiceTest.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package com.mageddo.dnsproxyserver.config.application;
22

3+
import java.nio.file.Paths;
4+
35
import com.mageddo.dnsproxyserver.config.dataformat.v2.cmdargs.ConfigDAOCmdArgs;
46
import com.mageddo.dnsproxyserver.config.dataformat.v2.legacyenv.ConfigDAOLegacyEnv;
7+
58
import org.hamcrest.CoreMatchers;
69
import org.junit.jupiter.api.Test;
710
import org.junit.jupiter.api.extension.ExtendWith;
811
import org.mockito.InjectMocks;
912
import org.mockito.Mock;
1013
import org.mockito.Spy;
1114
import org.mockito.junit.jupiter.MockitoExtension;
15+
1216
import testing.templates.ConfigFlagTemplates;
1317
import testing.templates.config.ConfigEnvTemplates;
1418

15-
import java.nio.file.Paths;
16-
1719
import static org.hamcrest.MatcherAssert.assertThat;
1820
import static org.junit.jupiter.api.Assertions.assertTrue;
1921
import static org.mockito.Mockito.doReturn;
@@ -35,13 +37,13 @@ class ConfigFileFinderServiceTest {
3537
void mustUseEnvConfig() {
3638
// arrange
3739
doReturn(ConfigEnvTemplates.withConfigFilePath())
38-
.when(this.configDAOEnv)
39-
.findRaw()
40+
.when(this.configDAOEnv)
41+
.findRaw()
4042
;
4143

4244
doReturn(ConfigFlagTemplates.withConfigFilePath())
43-
.when(this.configDAOCmdArgs)
44-
.findRaw()
45+
.when(this.configDAOCmdArgs)
46+
.findRaw()
4547
;
4648

4749
// act
@@ -56,13 +58,13 @@ void mustUseEnvConfig() {
5658
void mustUseArgsConfigWhenEnvNotSet() {
5759
// arrange
5860
doReturn(ConfigEnvTemplates.empty())
59-
.when(this.configDAOEnv)
60-
.findRaw()
61+
.when(this.configDAOEnv)
62+
.findRaw()
6163
;
6264

6365
doReturn(ConfigFlagTemplates.withConfigFilePath())
64-
.when(this.configDAOCmdArgs)
65-
.findRaw()
66+
.when(this.configDAOCmdArgs)
67+
.findRaw()
6668
;
6769

6870
// act
@@ -78,13 +80,13 @@ void mustUseArgsConfigWhenEnvNotSet() {
7880
void mustUseRandomGeneratedConfigPathWhenRunningInTestsAndNoCustomPathIsSpecified() {
7981
// arrange
8082
doReturn(ConfigEnvTemplates.empty())
81-
.when(this.configDAOEnv)
82-
.findRaw()
83+
.when(this.configDAOEnv)
84+
.findRaw()
8385
;
8486

8587
doReturn(ConfigFlagTemplates.empty())
86-
.when(this.configDAOCmdArgs)
87-
.findRaw()
88+
.when(this.configDAOCmdArgs)
89+
.findRaw()
8890
;
8991

9092
// act

0 commit comments

Comments
 (0)