24
24
import org .junit .jupiter .api .Test ;
25
25
import org .springframework .beans .factory .annotation .Autowired ;
26
26
import org .springframework .core .ParameterizedTypeReference ;
27
+ import org .springframework .http .HttpStatus ;
28
+ import org .springframework .test .web .reactive .server .ExchangeResult ;
27
29
import org .springframework .test .web .reactive .server .WebTestClient ;
28
30
29
31
@ Slf4j
@@ -45,6 +47,7 @@ public class KafkaConnectServiceTests extends AbstractIntegrationTest {
45
47
46
48
@ BeforeEach
47
49
public void setUp () {
50
+
48
51
webTestClient .post ()
49
52
.uri ("/api/clusters/{clusterName}/connects/{connectName}/connectors" , LOCAL , connectName )
50
53
.bodyValue (new NewConnectorDTO ()
@@ -54,11 +57,10 @@ public void setUp() {
54
57
"tasks.max" , "1" ,
55
58
"topics" , "output-topic" ,
56
59
"file" , "/tmp/test" ,
57
- "test.password" , "test-credentials"
58
- ))
59
- )
60
+ "test.password" , "test-credentials" )))
60
61
.exchange ()
61
62
.expectStatus ().isOk ();
63
+
62
64
}
63
65
64
66
@ AfterEach
@@ -418,4 +420,56 @@ public void shouldReturn400WhenTryingToCreateConnectorWithExistingName() {
418
420
.expectStatus ()
419
421
.isBadRequest ();
420
422
}
423
+
424
+ @ Test
425
+ public void shouldResetConnectorWhenInStoppedState () {
426
+
427
+ webTestClient .get ()
428
+ .uri ("/api/clusters/{clusterName}/connects/{connectName}/connectors/{connectorName}" ,
429
+ LOCAL , connectName , connectorName )
430
+ .exchange ()
431
+ .expectStatus ().isOk ()
432
+ .expectBody (ConnectorDTO .class )
433
+ .value (connector -> assertThat (connector .getStatus ().getState ()).isEqualTo (ConnectorStateDTO .RUNNING ));
434
+
435
+ webTestClient .post ()
436
+ .uri ("/api/clusters/{clusterName}/connects/{connectName}/connectors/{connectorName}/action/STOP" ,
437
+ LOCAL , connectName , connectorName )
438
+ .exchange ()
439
+ .expectStatus ().isOk ();
440
+
441
+ webTestClient .get ()
442
+ .uri ("/api/clusters/{clusterName}/connects/{connectName}/connectors/{connectorName}" ,
443
+ LOCAL , connectName , connectorName )
444
+ .exchange ()
445
+ .expectStatus ().isOk ()
446
+ .expectBody (ConnectorDTO .class )
447
+ .value (connector -> assertThat (connector .getStatus ().getState ()).isEqualTo (ConnectorStateDTO .STOPPED ));
448
+
449
+ webTestClient .delete ()
450
+ .uri ("/api/clusters/{clusterName}/connects/{connectName}/connectors/{connectorName}/offsets" ,
451
+ LOCAL , connectName , connectorName )
452
+ .exchange ()
453
+ .expectStatus ().isOk ();
454
+
455
+ }
456
+
457
+ @ Test
458
+ public void shouldReturn400WhenResettingConnectorInRunningState () {
459
+
460
+ webTestClient .get ()
461
+ .uri ("/api/clusters/{clusterName}/connects/{connectName}/connectors/{connectorName}" ,
462
+ LOCAL , connectName , connectorName )
463
+ .exchange ()
464
+ .expectStatus ().isOk ()
465
+ .expectBody (ConnectorDTO .class )
466
+ .value (connector -> assertThat (connector .getStatus ().getState ()).isEqualTo (ConnectorStateDTO .RUNNING ));
467
+
468
+ webTestClient .delete ()
469
+ .uri ("/api/clusters/{clusterName}/connects/{connectName}/connectors/{connectorName}/offsets" , LOCAL ,
470
+ connectName , connectorName )
471
+ .exchange ()
472
+ .expectStatus ().isBadRequest ();
473
+
474
+ }
421
475
}
0 commit comments