Skip to content

Commit eebd3e8

Browse files
committed
Fix warnings
1 parent a54cf91 commit eebd3e8

4 files changed

Lines changed: 23 additions & 19 deletions

File tree

src/test/java/cf/maybelambda/httpvalidator/springboot/itest/AppConfigurationControllerIntegrationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
@ActiveProfiles("test")
5757
@SpringBootTest
5858
public class AppConfigurationControllerIntegrationTests {
59-
public static String UPD_DATAFILE_ERRORS_DESCR = INVALID_DATA_FILE_ERROR_MSG + " or " + UPD_DATA_FILE_ERROR_MSG;
59+
public static final String UPD_DATAFILE_ERRORS_DESCR = INVALID_DATA_FILE_ERROR_MSG + " or " + UPD_DATA_FILE_ERROR_MSG;
6060
private String testsToken;
6161
private MockMvc mockMvc;
6262

@@ -138,12 +138,12 @@ public void canUpdateDataFileWithValidXML() throws Exception {
138138
.andDo(document("{method-name}", REQUEST_HEADERS_SNIPPET));
139139

140140
assertThat(this.dao.isDataFileStatusOk()).isTrue();
141-
assertThat(this.dao.getAll().get(0)).isEqualTo(task);
141+
assertThat(this.dao.getAll().getFirst()).isEqualTo(task);
142142
}
143143

144144
@Test
145145
public void error400WhenUpdateDataFileRequestWithInvalidXML() throws Exception {
146-
ValidationTask task = this.dao.getAll().get(0);
146+
ValidationTask task = this.dao.getAll().getFirst();
147147

148148
String xmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
149149
+ "<validations>"
@@ -175,6 +175,6 @@ public void error400WhenUpdateDataFileRequestWithInvalidXML() throws Exception {
175175
);
176176

177177
// Verify the original file contents have not been modified
178-
assertThat(this.dao.getAll().get(0)).isEqualTo(task);
178+
assertThat(this.dao.getAll().getFirst()).isEqualTo(task);
179179
}
180180
}

src/test/java/cf/maybelambda/httpvalidator/springboot/itest/AppInfoControllerIntegrationTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ public class AppInfoControllerIntegrationTests {
5151
);
5252
public static final String START_TIME_DESCR = "The start time of the application in a formatted string";
5353
public static final String START_TIME_LR_DESCR = "The start time of the last run in a formatted string";
54-
public static final String DATAFILE_STATUS_DESCR = "`OK`: Data file status is okay, i.e. it "
55-
+ "exists and is readable\n\n`ERROR`: Data file status is not okay";
56-
public static final String CONFIG_STATUS_DESCR = "`OK`: Both mail and validation configurations are okay (run "
57-
+ "schedule, credentials, from and to addresses)\n\n`ERROR`: Either mail or validation configuration is not okay";
54+
public static final String DATAFILE_STATUS_DESCR = """
55+
`OK`: Data file status is okay, i.e. it exists and is readable
56+
57+
`ERROR`: Data file status is not okay""";
58+
public static final String CONFIG_STATUS_DESCR = """
59+
`OK`: Both mail and validation configurations are okay (run schedule, credentials, from and to addresses)
60+
61+
`ERROR`: Either mail or validation configuration is not okay""";
5862
public static final String TIME_ELAPSED_DESCR = "Duration of the last run";
5963
public static final String TASKS_TOTAL_DESCR = "The total number of tasks to be processed in the last run";
6064
public static final String TASKS_OK_DESCR = "The number of tasks with expected results";

src/test/java/cf/maybelambda/httpvalidator/springboot/persistence/XMLValidationTaskDaoTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ void taskDataIsReadWhenWellFormedXMLParsedWithoutErrors() throws Exception {
127127

128128
List<ValidationTask> ans = this.taskDao.getAll();
129129

130-
assertEquals(GET, ans.get(0).reqMethod());
131-
assertEquals(this.url.getTextContent(), ans.get(0).reqURL());
132-
assertEquals(this.header.getTextContent(), ans.get(0).reqHeaders().get(0));
133-
assertEquals(this.mapper.readTree(this.reqbody.getTextContent()), ans.get(0).reqBody());
134-
assertEquals(Integer.parseInt(this.resBodyAttrs.getNamedItem(RES_SC_ATTR).getTextContent()), ans.get(0).validStatusCode());
135-
assertEquals(this.response.getTextContent(), ans.get(0).validBody());
130+
assertEquals(GET, ans.getFirst().reqMethod());
131+
assertEquals(this.url.getTextContent(), ans.getFirst().reqURL());
132+
assertEquals(this.header.getTextContent(), ans.getFirst().reqHeaders().getFirst());
133+
assertEquals(this.mapper.readTree(this.reqbody.getTextContent()), ans.getFirst().reqBody());
134+
assertEquals(Integer.parseInt(this.resBodyAttrs.getNamedItem(RES_SC_ATTR).getTextContent()), ans.getFirst().validStatusCode());
135+
assertEquals(this.response.getTextContent(), ans.getFirst().validBody());
136136
}
137137

138138
@Test
@@ -147,8 +147,8 @@ void xmlAttributesThatCanBeEmptyInDatafileAreParsedOk() throws Exception {
147147

148148
List<ValidationTask> ans = this.taskDao.getAll();
149149

150-
assertThat(ans.get(0).reqHeaders().isEmpty()).isTrue();
151-
assertEquals("", ans.get(0).validBody());
150+
assertThat(ans.getFirst().reqHeaders().isEmpty()).isTrue();
151+
assertEquals("", ans.getFirst().validBody());
152152
}
153153

154154
@Test
@@ -160,7 +160,7 @@ void whenGetAllThrowsSAXExceptionThenErrorIsLogged() throws Exception {
160160
}
161161

162162
@Test
163-
void whenJacksonThrowsJSONExceptionInGetAllThenErrorIsLogged() throws Exception {
163+
void whenJacksonThrowsJSONExceptionInGetAllThenErrorIsLogged() {
164164
// Number of <validation> elements
165165
given(this.nodes.getLength()).willReturn(1);
166166
// 2 child nodes of <validation>: <url> and <reqbody>

src/test/java/cf/maybelambda/httpvalidator/springboot/service/ValidationServiceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void whenExceptionOccursDuringExecValidationsRequestNotificationIsSent() throws
117117

118118
this.vs.execValidations();
119119

120-
assertEquals(1, this.tasks.get(0).reqHeaders().size());
120+
assertEquals(1, this.tasks.getFirst().reqHeaders().size());
121121
verify(this.ns).sendVTaskErrorsNotification(anyList());
122122
}
123123

@@ -134,7 +134,7 @@ void execValidationsLogsValidTaskResult() throws Exception {
134134

135135
this.vs.execValidations();
136136

137-
assertThat(this.dao.getAll().get(0).reqHeaders().isEmpty()).isTrue();
137+
assertThat(this.dao.getAll().getFirst().reqHeaders().isEmpty()).isTrue();
138138
verify(this.logger).info(anyString());
139139
}
140140

0 commit comments

Comments
 (0)