11package org .eclipse .dataplane ;
22
33import com .github .tomakehurst .wiremock .WireMockServer ;
4- import com .github .tomakehurst .wiremock .stubbing .Scenario ;
54import org .eclipse .dataplane .domain .Result ;
65import org .eclipse .dataplane .domain .dataflow .DataFlowPrepareMessage ;
76import org .eclipse .dataplane .port .exception .DataFlowNotFoundException ;
7+ import org .eclipse .dataplane .port .exception .DataFlowNotifyCompletedFailed ;
88import org .eclipse .dataplane .port .exception .DataplaneNotRegistered ;
99import org .junit .jupiter .api .AfterEach ;
1010import org .junit .jupiter .api .BeforeEach ;
1111import org .junit .jupiter .api .Nested ;
1212import org .junit .jupiter .api .Test ;
1313
14- import java .util . concurrent . TimeUnit ;
14+ import java .net . ConnectException ;
1515
1616import static com .github .tomakehurst .wiremock .client .WireMock .aResponse ;
1717import static com .github .tomakehurst .wiremock .client .WireMock .and ;
@@ -52,7 +52,7 @@ void shouldFail_whenDataFlowDoesNotExist() {
5252
5353 var result = dataplane .notifyCompleted ("dataFlowId" );
5454
55- assertThat (result .failed ());
55+ assertThat (result .failed ()). isTrue () ;
5656 assertThatThrownBy (result ::orElseThrow ).isExactlyInstanceOf (DataFlowNotFoundException .class );
5757 }
5858
@@ -64,8 +64,8 @@ void shouldReturnFailedFuture_whenControlPlaneIsNotAvailable() {
6464
6565 var result = dataplane .notifyCompleted ("dataFlowId" );
6666
67- assertThat (result .succeeded () );
68- assertThat (result . getContent ()). failsWithin ( 5 , TimeUnit . SECONDS );
67+ assertThat (result .failed ()). isTrue ( );
68+ assertThatThrownBy (result :: orElseThrow ). isExactlyInstanceOf ( ConnectException . class );
6969 }
7070
7171 @ Test
@@ -77,8 +77,8 @@ void shouldReturnFailedFuture_whenControlPlaneRespondWithError() {
7777
7878 var result = dataplane .notifyCompleted ("dataFlowId" );
7979
80- assertThat (result .succeeded () );
81- assertThat (result . getContent ()). failsWithin ( 5 , TimeUnit . SECONDS );
80+ assertThat (result .failed ()). isTrue ( );
81+ assertThatThrownBy (result :: orElseThrow ). isExactlyInstanceOf ( DataFlowNotifyCompletedFailed . class );
8282 assertThat (dataplane .status ("dataFlowId" ).getContent ().state ()).isNotEqualTo (COMPLETED .name ());
8383 }
8484
@@ -90,29 +90,7 @@ void shouldTransitionToCompleted_whenControlPlaneRespondCorrectly() {
9090
9191 var result = dataplane .notifyCompleted ("dataFlowId" );
9292
93- assertThat (result .succeeded ());
94- assertThat (result .getContent ()).succeedsWithin (5 , TimeUnit .SECONDS );
95- assertThat (dataplane .status ("dataFlowId" ).getContent ().state ()).isEqualTo (COMPLETED .name ());
96- }
97-
98- @ Test
99- void shouldRetryForCertainAmountOfCalls () {
100- controlPlane .stubFor (post (anyUrl ()).inScenario ("retry" )
101- .whenScenarioStateIs (Scenario .STARTED )
102- .willReturn (aResponse ().withStatus (500 ))
103- .willSetStateTo ("RETRY" ));
104-
105- controlPlane .stubFor (post (anyUrl ()).inScenario ("retry" )
106- .whenScenarioStateIs ("RETRY" )
107- .willReturn (aResponse ().withStatus (200 )));
108-
109- var dataplane = Dataplane .newInstance ().onPrepare (Result ::success ).build ();
110- dataplane .prepare (createPrepareMessage ());
111-
112- var result = dataplane .notifyCompleted ("dataFlowId" );
113-
114- assertThat (result .succeeded ());
115- assertThat (result .getContent ()).succeedsWithin (5 , TimeUnit .SECONDS );
93+ assertThat (result .succeeded ()).isTrue ();
11694 assertThat (dataplane .status ("dataFlowId" ).getContent ().state ()).isEqualTo (COMPLETED .name ());
11795 }
11896
@@ -121,8 +99,6 @@ private DataFlowPrepareMessage createPrepareMessage() {
12199 controlPlane .baseUrl (), "Something-PUSH" , emptyList (), emptyMap ());
122100 }
123101
124- // TODO: retry case
125-
126102 }
127103
128104 @ Nested
0 commit comments