Search in sources :

Example 1 with UnstructuredDataWriterParam

use of com.linkedin.restli.server.annotations.UnstructuredDataWriterParam in project rest.li by linkedin.

the class TestArgumentBuilder method testUnstructuredDataWriterParam.

@Test
public void testUnstructuredDataWriterParam() {
    ServerResourceContext mockResourceContext = EasyMock.createMock(ServerResourceContext.class);
    mockResourceContext.setResponseEntityStream(EasyMock.anyObject());
    EasyMock.expectLastCall().once();
    EasyMock.expect(mockResourceContext.getRequestAttachmentReader()).andReturn(null);
    EasyMock.replay(mockResourceContext);
    @SuppressWarnings({ "unchecked", "rawtypes" }) final Parameter<UnstructuredDataWriterParam> param = new Parameter("RestLi Unstructured Data Writer", UnstructuredDataWriter.class, null, false, null, Parameter.ParamType.UNSTRUCTURED_DATA_WRITER_PARAM, false, AnnotationSet.EMPTY);
    List<Parameter<?>> parameters = Collections.singletonList(param);
    Object[] results = ArgumentBuilder.buildArgs(new Object[0], getMockResourceMethod(parameters), mockResourceContext, null, getMockResourceMethodConfig(false));
    UnstructuredDataWriter result = (UnstructuredDataWriter) results[0];
    Assert.assertNotNull(result);
    Assert.assertTrue(result.getOutputStream() instanceof ByteArrayOutputStream);
    EasyMock.verify(mockResourceContext);
}
Also used : ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) UnstructuredDataWriterParam(com.linkedin.restli.server.annotations.UnstructuredDataWriterParam) Parameter(com.linkedin.restli.internal.server.model.Parameter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnstructuredDataWriter(com.linkedin.restli.server.UnstructuredDataWriter) Test(org.testng.annotations.Test)

Aggregations

ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)1 Parameter (com.linkedin.restli.internal.server.model.Parameter)1 UnstructuredDataWriter (com.linkedin.restli.server.UnstructuredDataWriter)1 UnstructuredDataWriterParam (com.linkedin.restli.server.annotations.UnstructuredDataWriterParam)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Test (org.testng.annotations.Test)1