Skip to content

Commit 483ffb2

Browse files
committed
more changes in tests and style
1 parent 13ed7b9 commit 483ffb2

3 files changed

Lines changed: 31 additions & 15 deletions

File tree

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
<version>4.0.0-beta.15</version>
6262
<scope>test</scope>
6363
</dependency>
64+
<dependency>
65+
<groupId>org.awaitility</groupId>
66+
<artifactId>awaitility</artifactId>
67+
<version>4.3.0</version>
68+
<scope>test</scope>
69+
</dependency>
6470
</dependencies>
6571
<build>
6672
<plugins>

src/main/resources/css/style.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ styles.css
77
-fx-background-color: #ffffff, linear-gradient(to bottom, #8b0000, #ffd700);
88
-fx-background-insets: 0, 5;
99
-fx-background-radius: 0, 10;
10+
1011
}
1112
/*.list-view{*/
1213
/* -fx-background-color: linear-gradient(to bottom, #8b0000, #ffd700);*/
@@ -30,7 +31,6 @@ styles.css
3031
-fx-background-color: #e0e0e0;
3132
-fx-text-fill: #000000;
3233
}
33-
3434
/* ------------------------------------------------------------------- */
3535
/* 3. STYLA DEN MARKERADE CELLEN (SELECTED) */
3636
/* ------------------------------------------------------------------- */
@@ -48,10 +48,15 @@ styles.css
4848
-fx-font-weight: bold;
4949
}
5050
.text-area{
51-
-fx-padding: 10px 20px;
51+
-fx-padding: 5px 7px;
5252
-fx-text-fill: black;
53-
-fx-border-color: #ffd700 #ffd700 #ffd700;
53+
-fx-font-size: 14;
54+
-fx-border: 1px solid #ccc;
55+
-fx-border-radius: 8px;
56+
-fx-background-color: transparent;
57+
-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.2), 5, 0, 0, 0);
5458
}
59+
.text-area:focus {}
5560
.button{
5661
-fx-background-color: #007bff;
5762
-fx-text-fill: white;

src/test/java/com/example/HelloModelTest.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import org.junit.jupiter.api.BeforeAll;
1010
import org.junit.jupiter.api.DisplayName;
1111
import org.junit.jupiter.api.Test;
12+
import org.awaitility.Awaitility;
1213

14+
import java.time.Duration;
1315
import java.util.concurrent.ExecutionException;
1416

1517
import static com.github.tomakehurst.wiremock.client.WireMock.*;
@@ -70,34 +72,37 @@ void checkReceivedMessagesAfterSendingAMessageToServer() throws InterruptedExcep
7072
model.setMessageToSend("Hello World");
7173
//Act - When
7274

73-
model.sendMessage();
74-
75-
model.receiveMessage();
76-
77-
Thread.sleep(1000);
75+
model.sendMessage().join();
7876

79-
var messageList = model.getMessages();
8077
//Assert
81-
assertThat(messageList).extracting(NtfyMessageDto::message).contains("Hello World");
78+
Awaitility.await()
79+
.atMost(Duration.ofSeconds(5))
80+
.pollInterval(Duration.ofMillis(100))
81+
.untilAsserted(() -> {
82+
assertThat(model.getMessages()).isNotEmpty();
83+
assertThat(model.getMessages().getLast().message()).contains("Hello World");
84+
});
8285
}
8386

8487
@Test
8588
void checkReceivedMessagesAfterSendingAMessageToAFakeServer(WireMockRuntimeInfo wmRunTimeInfo) throws InterruptedException {
8689
// Arrange
8790
var conImp = new NtfyConnectionImpl("http://localhost:" + wmRunTimeInfo.getHttpPort());
8891

89-
//stubFor(get("/mytopic/json").willReturn(ok("{\"message\":\"hej\"}")));
9092
stubFor(get("/mytopic/json")
9193
.willReturn(aResponse()
9294
.withHeader("Content-type", "application/json")
9395
.withBody("{\"event\": \"message\",\"message\": \"Hello World\", \"time\": \"12314244\"}")));
9496

9597
var model = new HelloModel(conImp);
9698

97-
Thread.sleep(1000);
98-
99-
assertThat(model.getMessages().getLast().message()).isEqualTo("Hello World");
100-
99+
Awaitility.await()
100+
.atMost(Duration.ofSeconds(4))
101+
.pollInterval(Duration.ofMillis(100)) // Kolla var 100:e ms
102+
.untilAsserted(() -> {
103+
assertThat(model.getMessages()).isNotEmpty();
104+
assertThat(model.getMessages().getLast().message()).isEqualTo("Hello World");
105+
});
101106
}
102107

103108
// Test som skickar in ett fake:at meddelande via record och kollar att meddelandet finns i observablelistan

0 commit comments

Comments
 (0)