-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODINVSTOR-1262 improve test coverage, update readme
- Loading branch information
1 parent
3c47801
commit e823d77
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...rg/folio/services/consortium/processor/ServicePointSynchronizationEventProcessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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 -> { | ||
if (ar.failed()) { | ||
testContext.verify(() -> { | ||
assertTrue(ar.cause() instanceof NullPointerException); | ||
testContext.completeNow(); | ||
}); | ||
} else { | ||
testContext.failNow(new RuntimeException("Expected the method to fail due to null ServicePointService")); | ||
} | ||
}); | ||
} | ||
} |