use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-inventory by folio-org.
the class CreateMarcHoldingsEventHandlerTest method setUp.
@Before
public void setUp() throws IOException {
MockitoAnnotations.openMocks(this);
MappingManager.clearReaderFactories();
MappingMetadataCache mappingMetadataCache = new MappingMetadataCache(vertx, vertx.createHttpClient(), 3600);
createMarcHoldingsEventHandler = new CreateMarcHoldingsEventHandler(storage, mappingMetadataCache, holdingsIdStorageService);
mappingRules = new JsonObject(TestUtil.readFileFromPath(MAPPING_RULES_PATH));
doAnswer(invocationOnMock -> {
instanceId = String.valueOf(UUID.randomUUID());
Instance instance = new Instance(instanceId, "2", String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID()));
List<Instance> instanceList = Collections.singletonList(instance);
MultipleRecords<Instance> result = new MultipleRecords<>(instanceList, 1);
Consumer<Success<MultipleRecords<Instance>>> successHandler = invocationOnMock.getArgument(2);
successHandler.accept(new Success<>(result));
return null;
}).when(instanceRecordCollection).findByCql(anyString(), any(PagingParameters.class), any(Consumer.class), any(Consumer.class));
doAnswer(invocationOnMock -> {
HoldingsRecord holdingsRecord = invocationOnMock.getArgument(0);
Consumer<Success<HoldingsRecord>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(holdingsRecord));
return null;
}).when(holdingsRecordsCollection).add(any(), any(Consumer.class), any(Consumer.class));
doAnswer(invocationOnMock -> {
recordId = String.valueOf(UUID.randomUUID());
holdingsId = String.valueOf(UUID.randomUUID());
RecordToEntity recordToHoldings = RecordToEntity.builder().recordId(recordId).entityId(holdingsId).build();
return Future.succeededFuture(recordToHoldings);
}).when(holdingsIdStorageService).store(any(), any(), any());
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters())).withMappingRules(mappingRules.encode())))));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-inventory by folio-org.
the class CreateAuthorityEventHandlerTest method setUp.
@Before
public void setUp() throws IOException {
MockitoAnnotations.openMocks(this);
MappingManager.clearReaderFactories();
MappingMetadataCache mappingMetadataCache = new MappingMetadataCache(vertx, vertx.createHttpClient(), 3600);
createMarcAuthoritiesEventHandler = new CreateAuthorityEventHandler(storage, mappingMetadataCache, authorityIdStorageService);
JsonObject mappingRules = new JsonObject(TestUtil.readFileFromPath(MAPPING_RULES_PATH));
doAnswer(invocationOnMock -> {
Authority authority = invocationOnMock.getArgument(0);
Consumer<Success<Authority>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(authority));
return null;
}).when(authorityCollection).add(any(), any(), any());
doAnswer(invocationOnMock -> {
RecordToEntity recordToItem = RecordToEntity.builder().recordId(RECORD_ID).entityId(AUTHORITY_ID).build();
return Future.succeededFuture(recordToItem);
}).when(authorityIdStorageService).store(any(), any(), any());
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters())).withMappingRules(mappingRules.encode())))));
doAnswer(invocationOnMock -> completedStage(new Response(HttpStatus.SC_CREATED, null, null, null))).when(mockedClient).post(any(URL.class), any(JsonObject.class));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-inventory by folio-org.
the class CreateInstanceEventHandlerTest method setUp.
@Before
public void setUp() throws IOException {
MockitoAnnotations.openMocks(this);
MappingManager.clearReaderFactories();
JsonObject mappingRules = new JsonObject(TestUtil.readFileFromPath(MAPPING_RULES_PATH));
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters())).withMappingRules(mappingRules.toString())))));
Vertx vertx = Vertx.vertx();
createInstanceEventHandler = new CreateInstanceEventHandler(storage, new PrecedingSucceedingTitlesHelper(context -> mockedClient), new MappingMetadataCache(vertx, vertx.createHttpClient(new HttpClientOptions().setConnectTimeout(3000)), 3600), instanceIdStorageService);
doAnswer(invocationOnMock -> {
Instance instanceRecord = invocationOnMock.getArgument(0);
Consumer<Success<Instance>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(instanceRecord));
return null;
}).when(instanceRecordCollection).add(any(), any(Consumer.class), any(Consumer.class));
doAnswer(invocationOnMock -> completedStage(createdResponse())).when(mockedClient).post(any(URL.class), any(JsonObject.class));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-inventory by folio-org.
the class UpdateAuthorityEventHandlerTest method setUp.
@Before
public void setUp() throws IOException {
MockitoAnnotations.openMocks(this);
MappingManager.clearReaderFactories();
MappingMetadataCache mappingMetadataCache = new MappingMetadataCache(vertx, vertx.createHttpClient(), 3600);
eventHandler = new UpdateAuthorityEventHandler(storage, mappingMetadataCache, publisher);
JsonObject mappingRules = new JsonObject(TestUtil.readFileFromPath(MAPPING_RULES_PATH));
doAnswer(invocationOnMock -> {
Consumer<Success<Void>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(null));
return null;
}).when(authorityCollection).update(any(), any(), any());
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters())).withMappingRules(mappingRules.encode())))));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-inventory by folio-org.
the class DataImportConsumerVerticleTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.openMocks(this);
when(mockedEventHandler.isEligible(any(DataImportEventPayload.class))).thenReturn(true);
doAnswer(invocationOnMock -> {
DataImportEventPayload eventPayload = invocationOnMock.getArgument(0);
eventPayload.setCurrentNode(eventPayload.getCurrentNode().getChildSnapshotWrappers().get(0));
return CompletableFuture.completedFuture(eventPayload);
}).when(mockedEventHandler).handle(any(DataImportEventPayload.class));
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(JOB_PROFILE_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(profileSnapshotWrapper))));
EventManager.clearEventHandlers();
EventManager.registerEventHandler(mockedEventHandler);
}
Aggregations