Skip to content

Commit a330641

Browse files
committed
chore(qulice): resolved all Qulice warnings
Refs: #58
1 parent ba8eedf commit a330641

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

src/main/java/ru/ewc/checklogic/TestResult.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,11 @@ private String classBasedOnSuccess() {
7070
}
7171

7272
@Override
73-
public int compareTo(TestResult o) {
74-
final int success = Boolean.compare(this.successful, o.successful);
75-
if (success == 0) {
76-
return this.file.compareTo(o.file);
77-
} else {
78-
return success;
73+
public int compareTo(final TestResult other) {
74+
int result = Boolean.compare(this.successful, other.successful);
75+
if (result == 0) {
76+
result = this.file.compareTo(other.file);
7977
}
78+
return result;
8079
}
8180
}

src/main/java/ru/ewc/checklogic/server/AllEndpoints.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ private Response getAddressFor(final Request request) {
9393
final Response result;
9494
final String address = request.requestLine().getPathDetails().getIsolatedPath();
9595
if (address.isEmpty()) {
96-
result = this.pages.indexPage();
96+
result = this.renderHtmlFor("templates/index.html");
9797
} else if ("test".equals(address)) {
9898
if (this.context.hasTestsFolder()) {
9999
result = this.pages.testPage();
100100
} else {
101-
result = this.pages.noTestsFolder();
101+
result = this.renderHtmlFor("templates/noTestsFolder.html");
102102
}
103103
} else if ("state".equals(address)) {
104104
result = this.pages.statePage(this.context);
@@ -108,6 +108,10 @@ private Response getAddressFor(final Request request) {
108108
return result;
109109
}
110110

111+
private Response renderHtmlFor(final String template) {
112+
return Response.htmlOk(this.pages.renderInLayout(template, Map.of()));
113+
}
114+
111115
private static Response staticResource(final Request request) {
112116
final Response result;
113117
if (request.requestLine().getPathDetails().getIsolatedPath().endsWith("main.css")) {

src/main/java/ru/ewc/checklogic/server/WebPages.java

+9-16
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,10 @@ public static WebPages testable() {
6868
return new WebPages(new MockTemplateRender(), "root folder");
6969
}
7070

71-
public Response indexPage() {
72-
return Response.htmlOk(this.renderInLayout("templates/index.html", Map.of()));
73-
}
74-
7571
public Response uninitializedPage() {
7672
return Response.htmlOk(this.renderInLayout("templates/uninitialized.html", Map.of()));
7773
}
7874

79-
public Response noTestsFolder() {
80-
return Response.htmlOk(this.renderInLayout("templates/noTestsFolder.html", Map.of()));
81-
}
82-
8375
public Response testPage() {
8476
final CheckSuite suite = CheckSuite.using(
8577
new CombinedCsvFileReader(Path.of(this.root, "tests").toUri(), ".csv", ";")
@@ -128,21 +120,22 @@ public Response statePage(final ServerInstance context) {
128120
);
129121
}
130122

131-
public String configPage() {
132-
return this.renderInLayout("templates/config.html", Map.of());
133-
}
134-
135-
private String renderInLayout(final String template, final Map<String, String> values) {
123+
public String renderInLayout(final String template, final Map<String, String> values) {
136124
return this.processors.renderInLayout(template, values);
137125
}
138126

139127
private static String resultAsUnorderedList(final Map.Entry<String, List<CheckFailure>> entry) {
140128
return "<ul>%s</ul>".formatted(String.join("", checkFailureAsHtml(entry.getValue())));
141129
}
142130

143-
private static String checkFailureAsHtml(final List<CheckFailure> failure) {
144-
return failure.stream()
145-
.map(f -> "<li>Expected: <kbd>%s</kbd>, but got: <kbd>%s</kbd></li>".formatted(f.expectation(), f.actual()))
131+
private static String checkFailureAsHtml(final List<CheckFailure> failures) {
132+
return failures.stream()
133+
.map(WebPages::formattedDescriptionFor)
146134
.collect(Collectors.joining());
147135
}
136+
137+
private static String formattedDescriptionFor(final CheckFailure failure) {
138+
return "<li>Expected: <kbd>%s</kbd>, but got: <kbd>%s</kbd></li>"
139+
.formatted(failure.expectation(), failure.actual());
140+
}
148141
}

src/test/java/ru/ewc/checklogic/server/WebPagesTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package ru.ewc.checklogic.server;
2525

26+
import java.util.Map;
2627
import org.hamcrest.MatcherAssert;
2728
import org.hamcrest.Matchers;
2829
import org.junit.jupiter.api.Test;
@@ -38,7 +39,7 @@ void shouldRenderConfigPage() {
3839
final WebPages pages = WebPages.testable();
3940
MatcherAssert.assertThat(
4041
"Should render the exact config page",
41-
pages.configPage(),
42+
pages.renderInLayout("templates/config.html", Map.of()),
4243
Matchers.is("Layout rendering")
4344
);
4445
}

0 commit comments

Comments
 (0)