Skip to content

Commit ece43ab

Browse files
author
TinaTiel
committed
Added assertion before cast, and renamed to make what (is now called) getPreviousResponseAs(...) is doing more clear.
1 parent a3d0113 commit ece43ab

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/integrationTest/java/net/twasi/obsremotejava/test/AbstractObsE2ETest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.twasi.obsremotejava.test;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
34
import static org.junit.jupiter.api.Assertions.fail;
45

56
import java.util.concurrent.BlockingQueue;
@@ -124,8 +125,10 @@ protected void waitReasonably(long ms) {
124125
resultQueue.add(obj);
125126
};
126127

127-
protected <T> T getResponseAs(Class<T> clazz) {
128-
return clazz.cast(resultQueue.remove());
128+
protected <T> T getPreviousResponseAs(Class<T> clazz) {
129+
Object previousResponse = resultQueue.remove();
130+
assertThat(previousResponse).isInstanceOf(clazz);
131+
return clazz.cast(previousResponse);
129132
}
130133

131134
}

src/integrationTest/java/net/twasi/obsremotejava/test/ObsRemoteE2eIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void getScenes() {
6161
waitReasonably();
6262

6363
// Then scenes match as expected
64-
GetSceneListResponse res = getResponseAs(GetSceneListResponse.class);
64+
GetSceneListResponse res = getPreviousResponseAs(GetSceneListResponse.class);
6565
assertThat(res.getScenes().stream().map(Scene::getName).collect(Collectors.toList()))
6666
.usingRecursiveComparison().ignoringCollectionOrder().isEqualTo(scenes);
6767

@@ -103,7 +103,7 @@ void getSourcesList() {
103103
waitReasonably();
104104

105105
// Then it matches as expected
106-
GetSourcesListResponse res = getResponseAs(GetSourcesListResponse.class);
106+
GetSourcesListResponse res = getPreviousResponseAs(GetSourcesListResponse.class);
107107
List<Source> sources = res.getSources();
108108
List<String> actualNames = sources.stream().map(Source::getName).collect(Collectors.toList());
109109
assertThat(actualNames.size()).isEqualTo(sources.size());

0 commit comments

Comments
 (0)