use of com.linkedin.data.template.StringMap in project rest.li by linkedin.
the class TestAsyncMethodInvocationPlanClass method individualRequest.
private static IndividualRequest individualRequest(String url, Map<String, String> headers, Map<String, IndividualRequest> dependentRequests) {
IndividualRequest individualRequest = new IndividualRequest();
individualRequest.setMethod(HttpMethod.GET.name());
individualRequest.setRelativeUrl(url);
if (headers != null && headers.size() > 0) {
individualRequest.setHeaders(new StringMap(headers));
}
individualRequest.setDependentRequests(new IndividualRequestMap(dependentRequests));
return individualRequest;
}
use of com.linkedin.data.template.StringMap in project rest.li by linkedin.
the class TestMultiplexerRunMode method individualRequest.
private static IndividualRequest individualRequest(String url, Map<String, String> headers, Map<String, IndividualRequest> dependentRequests) {
IndividualRequest individualRequest = new IndividualRequest();
individualRequest.setMethod(HttpMethod.GET.name());
individualRequest.setRelativeUrl(url);
if (headers != null && headers.size() > 0) {
individualRequest.setHeaders(new StringMap(headers));
}
individualRequest.setDependentRequests(new IndividualRequestMap(dependentRequests));
return individualRequest;
}
use of com.linkedin.data.template.StringMap in project rest.li by linkedin.
the class TestRestLiResponseHandler method testActions.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "statusActionData")
public void testActions(AcceptTypeData acceptTypeData, String response1, String response2, ProtocolVersion protocolVersion, String errorResponseHeaderName) throws Exception {
final RestRequest request = buildRequest(acceptTypeData.acceptHeaders, protocolVersion);
RestLiResponse response;
// #1 simple record template
RoutingResult routing = buildRoutingResultAction(Status.class, request, acceptTypeData.acceptHeaders);
response = buildPartialRestResponse(request, routing, buildStatusRecord());
checkResponse(response, 200, 1, true, errorResponseHeaderName);
if (acceptTypeData != AcceptTypeData.PSON) {
assertEquals(DataMapUtils.mapToByteString(response.getDataMap(), response.getHeaders()).asAvroString(), response1);
}
RestResponse restResponse = ResponseUtils.buildResponse(routing, response);
assertEquals(restResponse.getEntity().asAvroString(), response1);
// #2 DataTemplate response
StringMap map = new StringMap();
map.put("key1", "value1");
map.put("key2", "value2");
response = buildPartialRestResponse(request, buildRoutingResultAction(StringMap.class, request, acceptTypeData.acceptHeaders), map);
checkResponse(response, 200, 1, true, errorResponseHeaderName);
// Convert both of these back into maps depending on their response type
final DataMap actualMap;
final DataMap expectedMap;
if (acceptTypeData == AcceptTypeData.PSON) {
routing = buildRoutingResultAction(StringMap.class, request, acceptTypeData.acceptHeaders);
restResponse = ResponseUtils.buildResponse(routing, response);
actualMap = PSON_DATA_CODEC.bytesToMap(restResponse.getEntity().copyBytes());
expectedMap = PSON_DATA_CODEC.bytesToMap(ByteString.copyAvroString(response2, false).copyBytes());
} else {
actualMap = JACKSON_DATA_CODEC.bytesToMap(DataMapUtils.mapToByteString(response.getDataMap(), response.getHeaders()).copyBytes());
expectedMap = JACKSON_DATA_CODEC.stringToMap(response2);
}
assertEquals(actualMap, expectedMap);
// #3 empty response
response = buildPartialRestResponse(request, buildRoutingResultAction(Void.TYPE, request, acceptTypeData.acceptHeaders), null);
checkResponse(response, 200, 1, false, errorResponseHeaderName);
assertNull(response.getDataMap());
}
use of com.linkedin.data.template.StringMap in project rest.li by linkedin.
the class TestRestLiResponseHandler method testRestLiResponseData.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "statusActionDataPartial")
@SuppressWarnings("unchecked")
public void testRestLiResponseData(AcceptTypeData acceptTypeData, String response1, String response2, ProtocolVersion protocolVersion, String errorResponseHeaderName) throws Exception {
final RestRequest request = buildRequest(acceptTypeData.acceptHeaders, protocolVersion);
RestLiResponseData<ActionResponseEnvelope> responseData;
RoutingResult routingResult1 = buildRoutingResultAction(Status.class, request, acceptTypeData.acceptHeaders);
// #1 simple record template
responseData = (RestLiResponseData<ActionResponseEnvelope>) _responseHandler.buildRestLiResponseData(request, routingResult1, buildStatusRecord());
checkResponseData(responseData, HttpStatus.S_200_OK, 1, false, true, errorResponseHeaderName);
assertEquals(responseData.getResponseEnvelope().getRecord().toString(), response1);
// #2 DataTemplate response
StringMap map = new StringMap();
map.put("key1", "value1");
map.put("key2", "value2");
RoutingResult routingResult2 = buildRoutingResultAction(StringMap.class, request, acceptTypeData.acceptHeaders);
responseData = (RestLiResponseData<ActionResponseEnvelope>) _responseHandler.buildRestLiResponseData(request, routingResult2, map);
checkResponseData(responseData, HttpStatus.S_200_OK, 1, false, true, errorResponseHeaderName);
// Obtain the maps necessary for comparison
final DataMap actualMap;
final DataMap expectedMap;
actualMap = responseData.getResponseEnvelope().getRecord().data();
expectedMap = JACKSON_DATA_CODEC.stringToMap(response2);
assertEquals(actualMap, expectedMap);
RoutingResult routingResult3 = buildRoutingResultAction(Void.TYPE, request, acceptTypeData.acceptHeaders);
// #3 empty response
responseData = (RestLiResponseData<ActionResponseEnvelope>) _responseHandler.buildRestLiResponseData(request, routingResult3, null);
checkResponseData(responseData, HttpStatus.S_200_OK, 1, false, false, errorResponseHeaderName);
assertEquals(responseData.getResponseEnvelope().getRecord(), null);
}
use of com.linkedin.data.template.StringMap in project incubator-gobblin by apache.
the class GobblinServiceHATest method testBadUpdate.
@Test(dependsOnMethods = "testBadDelete")
public void testBadUpdate() throws Exception {
Map<String, String> flowProperties = Maps.newHashMap();
flowProperties.put("param1", "value1b");
flowProperties.put("param2", "value2b");
FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_DUMMY_GROUP_NAME_1).setFlowName(TEST_DUMMY_FLOW_NAME_1)).setTemplateUris(TEST_TEMPLATE_URI_1).setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE_1)).setProperties(new StringMap(flowProperties));
try {
this.node1FlowConfigClient.updateFlowConfig(flowConfig);
} catch (RestLiResponseException e) {
Assert.fail("Bad update should pass without complaining that the spec does not exists.");
}
try {
this.node2FlowConfigClient.updateFlowConfig(flowConfig);
} catch (RestLiResponseException e) {
Assert.fail("Bad update should pass without complaining that the spec does not exists.");
}
}
Aggregations