use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-inventory by folio-org.
the class DataImportKafkaHandlerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.openMocks(this);
String[] hostAndPort = cluster.getBrokerList().split(":");
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(JOB_PROFILE_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(profileSnapshotWrapper))));
KafkaConfig kafkaConfig = KafkaConfig.builder().kafkaHost(hostAndPort[0]).kafkaPort(hostAndPort[1]).maxRequestSize(1048576).build();
HttpClient client = vertx.createHttpClient(new HttpClientOptions().setConnectTimeout(3000));
dataImportKafkaHandler = new DataImportKafkaHandler(vertx, mockedStorage, client, new ProfileSnapshotCache(vertx, client, 3600), kafkaConfig, new MappingMetadataCache(vertx, client, 3600));
EventManager.clearEventHandlers();
EventManager.registerKafkaEventPublisher(kafkaConfig, vertx, 1);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-inventory by folio-org.
the class MappingMetadataCacheTest method shouldReturnEmptyOptionalWhenGetNotFoundOnSnapshotLoading.
@Test
public void shouldReturnEmptyOptionalWhenGetNotFoundOnSnapshotLoading(TestContext context) {
Async async = context.async();
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.notFound()));
Future<Optional<MappingMetadataDto>> optionalFuture = mappingMetadataCache.get(mappingMetadata.getJobExecutionId(), this.context);
optionalFuture.onComplete(ar -> {
context.assertTrue(ar.succeeded());
context.assertTrue(ar.result().isEmpty());
async.complete();
});
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-inventory by folio-org.
the class MappingMetadataCacheTest method shouldReturnFailedFutureWhenGetServerErrorOnSnapshotLoading.
@Test
public void shouldReturnFailedFutureWhenGetServerErrorOnSnapshotLoading(TestContext context) {
Async async = context.async();
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.serverError()));
Future<Optional<MappingMetadataDto>> optionalFuture = mappingMetadataCache.get(mappingMetadata.getJobExecutionId(), this.context);
optionalFuture.onComplete(ar -> {
context.assertTrue(ar.failed());
async.complete();
});
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project neow3j by neow3j.
the class NeoTokenTest method getUnclaimedGas.
@Test
public void getUnclaimedGas() throws IOException {
String responseBody = loadFile("/responses/invokefunction_unclaimedgas.json");
WireMock.stubFor(post(urlEqualTo("/")).withRequestBody(new RegexPattern("" + ".*\"method\":\"invokefunction\"" + ".*\"params\":" + ".*\"" + NEOTOKEN_SCRIPTHASH + "\"" + // function
".*\"unclaimedGas\"" + ".*\"f68f181731a47036a99f04dad90043a744edec0f\"" + // script hash
".*100.*")).willReturn(aResponse().withStatus(200).withBody(responseBody)));
BigInteger result = new NeoToken(neow).unclaimedGas(Hash160.fromAddress("NMNB9beANndYi5bd8Cd3U35EMvzmWMDSy9"), 100);
assertThat(result, is(new BigInteger("60000000000")));
result = new NeoToken(neow).unclaimedGas(Account.fromAddress("NMNB9beANndYi5bd8Cd3U35EMvzmWMDSy9"), 100);
assertThat(result, is(new BigInteger("60000000000")));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project neow3j by neow3j.
the class NeoTokenTest method getNextBlockValidators.
@Test
public void getNextBlockValidators() throws IOException {
String responseBody = loadFile("/responses/invokefunction_getnextblockvalidators.json");
WireMock.stubFor(post(urlEqualTo("/")).withRequestBody(new RegexPattern("" + ".*\"method\":\"invokefunction\"" + ".*\"params\":" + ".*\"" + NEOTOKEN_SCRIPTHASH + "\"" + // function
".*\"getNextBlockValidators\".*")).willReturn(aResponse().withStatus(200).withBody(responseBody)));
List<ECPublicKey> result = new NeoToken(neow).getNextBlockValidators();
String expKeyHex = "02163946a133e3d2e0d987fb90cb01b060ed1780f1718e2da28edf13b965fd2b60";
ECPublicKey expKey = new ECPublicKey(hexStringToByteArray(expKeyHex));
assertThat(result, contains(expKey));
}
Aggregations