use of com.linkedin.restli.server.CreateKVResponse in project rest.li by linkedin.
the class TestCreateResponseBuilder method returnEntityDataProvider.
@DataProvider(name = "returnEntityData")
public Object[][] returnEntityDataProvider() {
CreateResponse createResponse = new CreateResponse(null, HttpStatus.S_201_CREATED);
Foo entity = new Foo().setStringField("value").setFruitsField(Fruits.APPLE);
CreateKVResponse<Integer, Foo> createKVResponse = new CreateKVResponse<>(null, entity);
return new Object[][] { { createResponse, true, false }, { createResponse, false, false }, { createKVResponse, true, true }, { createKVResponse, false, false } };
}
use of com.linkedin.restli.server.CreateKVResponse in project rest.li by linkedin.
the class TestCreateResponseBuilder method testProjectionInBuildRestLiResponseData.
@Test
public void testProjectionInBuildRestLiResponseData() throws URISyntaxException {
MaskTree maskTree = new MaskTree();
maskTree.addOperation(new PathSpec("fruitsField"), MaskOperation.POSITIVE_MASK_OP);
ServerResourceContext mockContext = EasyMock.createMock(ServerResourceContext.class);
EasyMock.expect(mockContext.isReturnEntityRequested()).andReturn(true);
EasyMock.expect(mockContext.getProjectionMask()).andReturn(maskTree);
EasyMock.expect(mockContext.getProjectionMode()).andReturn(ProjectionMode.AUTOMATIC);
EasyMock.expect(mockContext.getRawRequestContext()).andReturn(new RequestContext()).anyTimes();
EasyMock.expect(mockContext.getAlwaysProjectedFields()).andReturn(Collections.emptySet()).anyTimes();
EasyMock.replay(mockContext);
RoutingResult routingResult = new RoutingResult(mockContext, null);
Foo value = new Foo().setStringField("value").setFruitsField(Fruits.APPLE);
CreateKVResponse<Integer, Foo> values = new CreateKVResponse<>(null, value);
CreateResponseBuilder responseBuilder = new CreateResponseBuilder();
RestLiResponseData<CreateResponseEnvelope> envelope = responseBuilder.buildRestLiResponseData(new RestRequestBuilder(new URI("/foo")).build(), routingResult, values, Collections.emptyMap(), Collections.emptyList());
RecordTemplate record = envelope.getResponseEnvelope().getRecord();
Assert.assertEquals(record.data().size(), 1);
Assert.assertEquals(record.data().get("fruitsField"), Fruits.APPLE.toString());
Assert.assertTrue(envelope.getResponseEnvelope().isGetAfterCreate());
EasyMock.verify(mockContext);
}
use of com.linkedin.restli.server.CreateKVResponse in project rest.li by linkedin.
the class TestBatchCreateResponseBuilder method provideReturnEntityData.
@DataProvider(name = "returnEntityData")
public Object[][] provideReturnEntityData() {
CreateResponse createResponse = new CreateResponse(1L, HttpStatus.S_201_CREATED);
List<CreateResponse> createResponses = new ArrayList<>();
createResponses.add(createResponse);
BatchCreateResult<Long, Foo> batchCreateResult = new BatchCreateResult<>(createResponses);
Foo entity = new Foo().setStringField("value").setFruitsField(Fruits.APPLE);
CreateKVResponse<Long, Foo> createKVResponse = new CreateKVResponse<>(1L, entity);
List<CreateKVResponse<Long, Foo>> createKVResponses = new ArrayList<>();
createKVResponses.add(createKVResponse);
BatchCreateKVResult<Long, Foo> batchCreateKVResult = new BatchCreateKVResult<>(createKVResponses);
return new Object[][] { { batchCreateResult, createResponses, true, false }, { batchCreateResult, createResponses, false, false }, { batchCreateKVResult, createKVResponses, true, true }, { batchCreateKVResult, createKVResponses, false, false } };
}
Aggregations