本文整理汇总了Java中com.github.tomakehurst.wiremock.verification.LoggedRequest类的典型用法代码示例。如果您正苦于以下问题:Java LoggedRequest类的具体用法?Java LoggedRequest怎么用?Java LoggedRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoggedRequest类属于com.github.tomakehurst.wiremock.verification包,在下文中一共展示了LoggedRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldProduceUserAccountCreationJson
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void shouldProduceUserAccountCreationJson() throws Exception {
AttributeQuery attributeQuery = AttributeQueryBuilder.anAttributeQuery()
.withId(REQUEST_ID)
.withAttributes(asList())
.withIssuer(anIssuer().withIssuerId(HUB_ENTITY_ID).build())
.withSubject(aSubjectWithAssertions(asList(
anAuthnStatementAssertion(IdaAuthnContext.LEVEL_1_AUTHN_CTX, REQUEST_ID),
aMatchingDatasetAssertion(asList(), false, REQUEST_ID)
), REQUEST_ID, HUB_ENTITY_ID, PID))
.build();
makeAttributeQueryRequest(UNKNOWN_USER_URI, attributeQuery, signatureAlgorithmForHub, digestAlgorithmForHub, HUB_ENTITY_ID);
List<LoggedRequest> requests = findAll(RequestPatternBuilder.allRequests());
assertThat(requests.size()).isEqualTo(1);
Path filePath = Paths.get("verify-matching-service-test-tool/src/main/resources/user-account-creation.json");
Map requestSent = objectMapper.readValue(requests.get(0).getBodyAsString(), Map.class);
Map requestExpected = objectMapper.readValue(readExpectedJson(filePath), Map.class);
assertThat(requestSent).isEqualToComparingFieldByFieldRecursively(requestExpected);
}
示例2: shouldGetTheCorrectValueForGoodResponse
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void shouldGetTheCorrectValueForGoodResponse() throws Exception {
// prepare the server with canned response
wireMockRule.stubFor(post(urlMatching("/things/"))
.willReturn(aResponse()
.withStatus(201)));
// get the client
ClientInterface client = createRetrofitClient(serverUrl);
// create object to save
MyObject objectToSave = MyObject.create("I love JSON", 3);
// invoke the method
client.saveMyObjectToIdentifier(objectToSave);
// verify that the request was made correctly
wireMockRule.verify(postRequestedFor(urlEqualTo("/things/")));
List<LoggedRequest> requests = wireMockRule.findRequestsMatching(RequestPattern.everything()).getRequests();
assertThat(requests).hasSize(1);
final LoggedRequest lastRequest = requests.get(0);
MyObject fromJson = convertFromJson(lastRequest.getBody(), MyObject.class);
assertThat(fromJson.getFirstField()).contains("I love JSON");
assertThat(fromJson.getSecondField()).contains(3);
}
示例3: testClientFactoryDefault
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void testClientFactoryDefault() throws ResourceException, IOException {
wireMockRule.stubFor(get(TEST_PATTERN)
.willReturn(aResponse().withStatus(200)));
EnvironmentConfig environmentConfig = new EnvironmentConfig("test", HTTP_BASE_URL + ":" + wireMockRule.port(), Strategy.REPLACE);
ClientFactory clientFactory = new ClientFactory(environmentConfig);
ClientFactoryTestService clientFactoryTestService = clientFactory.create(ClientFactoryTestService.class);
clientFactoryTestService.test().execute();
wireMockRule.verify(1, getRequestedFor(TEST_PATTERN));
List<LoggedRequest> requests = wireMockRule.findAll(getRequestedFor(TEST_PATTERN));
LoggedRequest request = requests.get(0);
assertFalse(request.containsHeader("Authorization"));
}
示例4: setupWireMock
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Before
public void setupWireMock() throws Exception {
String fusionHostAndPort = "http://" + fusionHost + fusionApiPort;
fusionPipelineUrlWithoutHostAndPort = fusionProxyBaseUrl + fusionIndexingPipelineUrlExtension +
fusionIndexingPipeline + fusionCollectionApiStrValForUrl + fusionCollectionForUrl +
defaultFusionIndexingPipelineUrlTerminatingString;
fusionUrl = fusionHostAndPort + fusionPipelineUrlWithoutHostAndPort;
fusionSolrProxyWithoutHostAndPort = fusionSolrProxyUrlExtension + fusionCollectionForUrl;
wireMockRule.addMockServiceRequestListener(new RequestListener() {
@Override
public void requestReceived(Request request, Response response) {
loggedRequests.add(LoggedRequest.createFrom(request));
}
});
log.info("running with: fusionSolrProxyWithoutHostAndPort=" + fusionSolrProxyWithoutHostAndPort +
" fusionPipelineUrlWithoutHostAndPort=" + fusionPipelineUrlWithoutHostAndPort +
" wireMockRulePort=" + wireMockRulePort + " useWireMockRule=" + useWireMockRule);
}
示例5: addGroupNoMembers
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void addGroupNoMembers() throws CMCException {
stubFor(post(urlEqualTo("/groups"))
.willReturn(aResponse()
.withStatus(201)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
Group group = new Group();
group.setName("Test rest group api");
group.setDescription("Test rest group api description");
HttpResponseWrapper<RestResponse> response = groupApi.addGroup(group);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 201);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(postRequestedFor(urlMatching("/groups")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "{\"groups\":{\"groupname\":\"Test rest group api\",\"groupdesc\":\"Test rest group api description\"}}");
}
示例6: addInvalidGroupNoMembers
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void addInvalidGroupNoMembers() throws CMCException {
stubFor(post(urlEqualTo("/groups"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\":{\"status\":\"fail\",\"code\":\"7003\",\"message\":\"Group with name Test rest group api already exists.\"}}")));
Group group = new Group();
group.setName("Test rest group api");
group.setDescription("Test rest group api description");
HttpResponseWrapper<RestResponse> response = groupApi.addGroup(group);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 404);
assertEquals(response.getResponseBody().getStatus(), "fail");
assertEquals(response.getResponseBody().getCode(), "7003");
// Verify the request
List<LoggedRequest> requests = findAll(postRequestedFor(urlMatching("/groups")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "{\"groups\":{\"groupname\":\"Test rest group api\",\"groupdesc\":\"Test rest group api description\"}}");
}
示例7: addGroupMemberSingleMdn
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void addGroupMemberSingleMdn() throws CMCException {
stubFor(post(urlPathMatching("/groups/(.*)/members"))
.willReturn(aResponse()
.withStatus(201)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
String groupName = "Test rest group api";
GroupMembers groupMembers = new GroupMembers();
List<GroupMember> members = new ArrayList<GroupMember>();
GroupMember groupMember = new GroupMember();
groupMember.setMdn("14102951866");
members.add(groupMember);
groupMembers.setMembers(members);
HttpResponseWrapper<RestResponse> response = groupApi.addGroupMember(groupMembers, groupName);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 201);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(postRequestedFor(urlPathMatching("/groups/(.*)/members")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "{\"groupmembers\":{\"members\":[{\"mdn\":\"14102951866\"}]}}");
}
示例8: addGroupMemberSingleContact
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void addGroupMemberSingleContact() throws CMCException {
stubFor(post(urlPathMatching("/groups/(.*)/members"))
.willReturn(aResponse()
.withStatus(201)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
String groupName = "Test rest group api";
GroupMembers groupMembers = new GroupMembers();
List<GroupMember> members = new ArrayList<GroupMember>();
GroupMember groupMember = new GroupMember();
groupMember.setContactName("Doe-John");
members.add(groupMember);
groupMembers.setMembers(members);
HttpResponseWrapper<RestResponse> response = groupApi.addGroupMember(groupMembers, groupName);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 201);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(postRequestedFor(urlPathMatching("/groups/(.*)/members")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "{\"groupmembers\":{\"members\":[{\"contact\":\"Doe-John\"}]}}");
}
示例9: deleteGroupSingleMdnMember
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void deleteGroupSingleMdnMember() throws CMCException {
stubFor(delete(urlMatching("/groups/(.*)/members/(.*)"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
String groupName = "Test rest group api";
String members = "14102951866";
HttpResponseWrapper<RestResponse> response = groupApi.deleteGroupMember(groupName, members);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 200);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(deleteRequestedFor(urlMatching("/groups/(.*)/members/(.*)")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "");
}
示例10: deleteGroupMultipleMdnMembers
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void deleteGroupMultipleMdnMembers() throws CMCException {
stubFor(delete(urlMatching("/groups/(.*)/members/(.*)"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
String groupName = "Test rest group api";
StringBuffer members = new StringBuffer();
members.append("14102951866");
members.append(",");
members.append("14102951866");
HttpResponseWrapper<RestResponse> response = groupApi.deleteGroupMember(groupName, members.toString());
// Verify the response.
assertEquals(response.getHttpStatusCode(), 200);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(deleteRequestedFor(urlMatching("/groups/(.*)/members/(.*)")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "");
}
示例11: deleteGroupSingleContactMember
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void deleteGroupSingleContactMember() throws CMCException {
stubFor(delete(urlMatching("/groups/(.*)/members/(.*)"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
String groupName = "Test rest group api";
String members = "Doe-John";
HttpResponseWrapper<RestResponse> response = groupApi.deleteGroupMember(groupName, members);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 200);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(deleteRequestedFor(urlMatching("/groups/(.*)/members/(.*)")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "");
}
示例12: deleteGroupInvalidSingleContactMember
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void deleteGroupInvalidSingleContactMember() throws CMCException {
stubFor(delete(urlMatching("/groups/(.*)/members/(.*)"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\":{\"status\":\"fail\",\"code\":\"7304\",\"message\":\"Group members for group with name TEST REST GROUP API was not updated as some or all of the contacts do not exist.\"}}")));
String groupName = "Test rest group api";
String members = "Doe-John";
HttpResponseWrapper<RestResponse> response = groupApi.deleteGroupMember(groupName, members);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 404);
assertEquals(response.getResponseBody().getCode(), "7304");
assertEquals(response.getResponseBody().getStatus(), "fail");
// Verify the request
List<LoggedRequest> requests = findAll(deleteRequestedFor(urlMatching("/groups/(.*)/members/(.*)")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "");
}
示例13: deleteGroupMultipleContactMembers
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void deleteGroupMultipleContactMembers() throws CMCException {
stubFor(delete(urlMatching("/groups/(.*)/members/(.*)"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
String groupName = "Test rest group api";
StringBuffer members = new StringBuffer();
members.append("Doe-John");
members.append(",");
members.append("Wall-John");
HttpResponseWrapper<RestResponse> response = groupApi.deleteGroupMember(groupName, members.toString());
// Verify the response.
assertEquals(response.getHttpStatusCode(), 200);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(deleteRequestedFor(urlMatching("/groups/(.*)/members/(.*)")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "");
}
示例14: deleteSingleValidGroup
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void deleteSingleValidGroup() throws CMCException {
stubFor(delete(urlMatching("/groups/(.*)"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\": {\"status\": \"success\"}}")));
List<String> groupNames = new ArrayList<String>();
groupNames.add("Test rest group api");
HttpResponseWrapper<RestResponse> response = groupApi.deleteGroups(groupNames);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 200);
assertEquals(response.getResponseBody().getStatus(), "success");
// Verify the request
List<LoggedRequest> requests = findAll(deleteRequestedFor(urlMatching("/groups/(.*)")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "");
}
示例15: deleteSingleInValidGroup
import com.github.tomakehurst.wiremock.verification.LoggedRequest; //导入依赖的package包/类
@Test
public void deleteSingleInValidGroup() throws CMCException {
stubFor(delete(urlMatching("/groups/(.*)"))
.willReturn(aResponse()
.withStatus(404)
.withHeader("Content-Type", "application/json")
.withBody("{\"response\":{\"status\":\"fail\",\"code\":\"7103\",\"message\":\"Some or all of the groups with names Test rest group api not found.\"}}")));
List<String> groupNames = new ArrayList<String>();
groupNames.add("Test rest group api");
HttpResponseWrapper<RestResponse> response = groupApi.deleteGroups(groupNames);
// Verify the response.
assertEquals(response.getHttpStatusCode(), 404);
assertEquals(response.getResponseBody().getCode(), "7103");
assertEquals(response.getResponseBody().getStatus(), "fail");
// Verify the request
List<LoggedRequest> requests = findAll(deleteRequestedFor(urlMatching("/groups/(.*)")));
assertEquals(requests.size(), 1);
assertEquals(requests.get(0).getBodyAsString(), "");
}