Search in sources :

Example 6 with DynamicRecordTemplate

use of com.linkedin.data.template.DynamicRecordTemplate in project rest.li by linkedin.

the class TestGroupsRequestBuilders method testAction.

// Actions tests are covered in TestGroupsClient.java
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestGroupsBuilderDataProviderEntityAction")
public void testAction(RootBuilderWrapper<Integer, Group> builders, URIDetails expectedURIDetails) {
    String testEmail = "test@test.com";
    TransferOwnershipRequest ownershipRequest = new TransferOwnershipRequest();
    ownershipRequest.setNewOwnerContactEmail(testEmail);
    int testId = 9999;
    ownershipRequest.setNewOwnerMemberID(testId);
    Request<Void> request = builders.<Void>action("TransferOwnership").id(1).setActionParam("Request", ownershipRequest).build();
    Map<FieldDef<?>, Object> parameters = new HashMap<FieldDef<?>, Object>(1);
    parameters.put(new FieldDef<TransferOwnershipRequest>("request", TransferOwnershipRequest.class, DataTemplateUtil.getSchema(TransferOwnershipRequest.class)), ownershipRequest);
    DynamicRecordTemplate requestInput = createDynamicRecordTemplate("transferOwnership", parameters);
    checkRequestBuilder(request, ResourceMethod.ACTION, ActionResponseDecoder.class, expectedURIDetails, requestInput);
}
Also used : FieldDef(com.linkedin.data.template.FieldDef) DynamicRecordTemplate(com.linkedin.data.template.DynamicRecordTemplate) HashMap(java.util.HashMap) TransferOwnershipRequest(com.linkedin.restli.examples.groups.api.TransferOwnershipRequest) Test(org.testng.annotations.Test)

Example 7 with DynamicRecordTemplate

use of com.linkedin.data.template.DynamicRecordTemplate in project rest.li by linkedin.

the class TestGroupsRequestBuilders method testActionOnSubresource.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestContactsBuilderDataProviderAction")
public void testActionOnSubresource(RootBuilderWrapper<Integer, GroupContact> builders, URIDetails expectedURIDetails) {
    Request<Void> request = builders.<Void>action("SpamContacts").setPathKey("groupId", 42).build();
    Map<FieldDef<?>, Object> parameters = new HashMap<FieldDef<?>, Object>(1);
    DynamicRecordTemplate requestInput = createDynamicRecordTemplate("spamContacts", parameters);
    checkRequestBuilder(request, ResourceMethod.ACTION, ActionResponseDecoder.class, expectedURIDetails, requestInput);
}
Also used : FieldDef(com.linkedin.data.template.FieldDef) DynamicRecordTemplate(com.linkedin.data.template.DynamicRecordTemplate) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 8 with DynamicRecordTemplate

use of com.linkedin.data.template.DynamicRecordTemplate in project rest.li by linkedin.

the class TestArgumentBuilder method testPostParameterType.

@Test
public void testPostParameterType() {
    String testParamKey = "testParam";
    String expectedTestParamValue = "testParamValue";
    ServerResourceContext mockResourceContext = EasyMock.createMock(ServerResourceContext.class);
    DataMap entityBody = new DataMap();
    entityBody.put(testParamKey, expectedTestParamValue);
    DynamicRecordTemplate template = new DynamicRecordTemplate(entityBody, null);
    Parameter<String> param = new Parameter<String>(testParamKey, String.class, DataSchemaConstants.STRING_DATA_SCHEMA, false, null, Parameter.ParamType.POST, false, AnnotationSet.EMPTY);
    List<Parameter<?>> parameters = Collections.<Parameter<?>>singletonList(param);
    EasyMock.expect(mockResourceContext.getRequestAttachmentReader()).andReturn(null);
    Object[] results = ArgumentBuilder.buildArgs(new Object[0], getMockResourceMethod(parameters), mockResourceContext, template);
    Assert.assertEquals(results[0], expectedTestParamValue);
}
Also used : DynamicRecordTemplate(com.linkedin.data.template.DynamicRecordTemplate) ServerResourceContext(com.linkedin.restli.internal.server.ServerResourceContext) Parameter(com.linkedin.restli.internal.server.model.Parameter) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Aggregations

DynamicRecordTemplate (com.linkedin.data.template.DynamicRecordTemplate)8 FieldDef (com.linkedin.data.template.FieldDef)5 Test (org.testng.annotations.Test)5 DataMap (com.linkedin.data.DataMap)4 HashMap (java.util.HashMap)4 ByteString (com.linkedin.data.ByteString)2 DynamicRecordMetadata (com.linkedin.data.template.DynamicRecordMetadata)2 TestRecord (com.linkedin.restli.client.test.TestRecord)2 CompoundKey (com.linkedin.restli.common.CompoundKey)2 ResourceSpec (com.linkedin.restli.common.ResourceSpec)2 ResourceSpecImpl (com.linkedin.restli.common.ResourceSpecImpl)2 ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)2 Parameter (com.linkedin.restli.internal.server.model.Parameter)2 RecordDataSchema (com.linkedin.data.schema.RecordDataSchema)1 ValidationOptions (com.linkedin.data.schema.validation.ValidationOptions)1 ValidationResult (com.linkedin.data.schema.validation.ValidationResult)1 ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)1 TransferOwnershipRequest (com.linkedin.restli.examples.groups.api.TransferOwnershipRequest)1 ActionResponseDecoder (com.linkedin.restli.internal.client.ActionResponseDecoder)1 MutablePathKeys (com.linkedin.restli.internal.server.MutablePathKeys)1