Skip to content

Commit

Permalink
fix TU
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasCAI-mlv committed Aug 13, 2024
1 parent f0e0975 commit e600fc4
Showing 1 changed file with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -573,18 +573,47 @@ void shouldDeleteOldSchemaVersionAndNotSendEventLog() {
}

@Test
void shouldDeleteLatestSchemaVersion() {
void shouldDeleteLatestSchemaVersionBySpecifyingLatest() {
Namespace namespace = buildNamespace();
Schema schema = buildSchema();
Schema schema1 = buildSchema();
Schema schema2 = buildSchemaV2();

when(namespaceService.findByName("myNamespace"))
.thenReturn(Optional.of(namespace));
when(schemaService.isNamespaceOwnerOfSubject(namespace, "prefix.subject-value"))
.thenReturn(true);
when(schemaService.getSubject(namespace, "prefix.subject-value", "latest"))
.thenReturn(Mono.just(schema2));
when(schemaService.deleteVersion(namespace, "prefix.subject-value", "latest"))
.thenReturn(Mono.just(Optional.of(schema1)));
when(securityService.username())
.thenReturn(Optional.of("test-user"));
when(securityService.hasRole(ResourceBasedSecurityRule.IS_ADMIN))
.thenReturn(false);
doNothing().when(applicationEventPublisher).publishEvent(any());

StepVerifier.create(schemaController.delete("myNamespace", "prefix.subject-value",
Optional.of("latest"), false))
.consumeNextWith(response -> assertEquals(HttpStatus.NO_CONTENT, response.getStatus()))
.verifyComplete();

verify(applicationEventPublisher, times(1)).publishEvent(any());
}

@Test
void shouldDeleteLatestSchemaVersionBySpecifyingVersion() {
Namespace namespace = buildNamespace();
Schema schema1 = buildSchema();
Schema schema2 = buildSchemaV2();

when(namespaceService.findByName("myNamespace"))
.thenReturn(Optional.of(namespace));
when(schemaService.isNamespaceOwnerOfSubject(namespace, "prefix.subject-value"))
.thenReturn(true);
when(schemaService.getSubject(namespace, "prefix.subject-value", "2"))
.thenReturn(Mono.just(schema));
.thenReturn(Mono.just(schema2));
when(schemaService.deleteVersion(namespace, "prefix.subject-value", "2"))
.thenReturn(Mono.just(Optional.of(schema)));
.thenReturn(Mono.just(Optional.of(schema1)));
when(securityService.username())
.thenReturn(Optional.of("test-user"));
when(securityService.hasRole(ResourceBasedSecurityRule.IS_ADMIN))
Expand Down

0 comments on commit e600fc4

Please sign in to comment.