Skip to content

Commit

Permalink
MODINVSTOR-1262 improve test coverage, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk committed Nov 9, 2024
1 parent 3c47801 commit 258f166
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ These environment variables configure the module interaction with S3-compatible
* `S3_ACCESS_KEY_ID`
* `S3_SECRET_ACCESS_KEY`
* `S3_IS_AWS` (default value - `false`)
* `ECS_TLR_FEATURE_ENABLED` (default value - `false`)

# Local Deployment using Docker

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,26 @@ public void shouldPropagateDeleteOfServicePointOnLendingTenant(TestContext conte
context.assertEquals(HTTP_NOT_FOUND, statusCode)));
}

@Test
public void shouldHandleUpdateEventForNonExistingServicePoint(TestContext context) {
Servicepoint nonExistingServicePoint = new Servicepoint().withId(UUID.randomUUID().toString());
publishServicePointUpdateEvent(nonExistingServicePoint, nonExistingServicePoint);

getStatusCodeOfServicePointById(COLLEGE_TENANT_ID)
.onComplete(context.asyncAssertSuccess(statusCode ->
context.assertEquals(HTTP_NOT_FOUND, statusCode)));
}

@Test
public void shouldHandleDeleteEventForNonExistingServicePoint(TestContext context) {
Servicepoint nonExistingServicePoint = new Servicepoint().withId(UUID.randomUUID().toString());
publishServicePointDeleteEvent(nonExistingServicePoint);

getStatusCodeOfServicePointById(COLLEGE_TENANT_ID)
.onComplete(context.asyncAssertSuccess(statusCode ->
context.assertEquals(HTTP_NOT_FOUND, statusCode)));
}

@SneakyThrows
public static <T> T waitFor(Future<T> future, int timeoutSeconds) {
return future.toCompletionStage()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.folio.services.consortium.processor;

import static org.junit.Assert.assertTrue;

import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import org.folio.rest.jaxrs.model.Servicepoint;
import org.folio.services.domainevent.DomainEvent;
import org.folio.services.domainevent.DomainEventType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

@ExtendWith(VertxExtension.class)
public class ServicePointSynchronizationEventProcessorTest {
private ServicePointSynchronizationUpdateEventProcessor updateEventProcessor;
private ServicePointSynchronizationCreateEventProcessor createEventProcessor;

@BeforeEach
void setUp() {
Servicepoint newServicepoint = new Servicepoint();
Servicepoint oldServicepoint = new Servicepoint();
updateEventProcessor = new ServicePointSynchronizationUpdateEventProcessor(new DomainEvent<>(
oldServicepoint, newServicepoint, DomainEventType.UPDATE, "tenant"));
createEventProcessor = new ServicePointSynchronizationCreateEventProcessor(
new DomainEvent<>(oldServicepoint, newServicepoint, DomainEventType.CREATE, "tenant")
);
}

@Test
void shouldFailToUpdateEventDueToNullServicePointService(VertxTestContext testContext) {
processEventToThrowException(updateEventProcessor, testContext);
}

@Test
void shouldFailToCreateEventDueToNullServicePointService(VertxTestContext testContext) {
processEventToThrowException(createEventProcessor, testContext);
}

private void processEventToThrowException(ServicePointSynchronizationEventProcessor processor,
VertxTestContext testContext) {

processor.processEvent(null, "")
.onComplete(ar ->
testContext.verify(() -> {
assertTrue(ar.cause() instanceof NullPointerException);
testContext.completeNow();
}));
}
}

0 comments on commit 258f166

Please sign in to comment.