Package com.linkedin.data.template

Examples of com.linkedin.data.template.DynamicRecordMetadata


  private void compareActions(ResourceSpec actual, ResourceSpec expected, ActionSchemaArray actions)
  {
    for (ActionSchema action : actions)
    {
      ParameterSchemaArray parameters = action.getParameters();
      DynamicRecordMetadata actualRequest = actual.getRequestMetadata(action.getName());
      DynamicRecordMetadata expectedRequest = expected.getRequestMetadata(action.getName());
      if (expectedRequest != null)
      {
        Assert.assertNotNull(actualRequest);
        Assert.assertEquals(actualRequest.getRecordDataSchema(), expectedRequest.getRecordDataSchema());

        if (parameters != null)
        {
          for (ParameterSchema parameter : parameters)
          {
            compareFieldDef(actualRequest.getFieldDef(parameter.getName()), expectedRequest.getFieldDef(parameter.getName()));
          }
        }
      }
      else
      {
View Full Code Here


    if (actionSchema == null)
    {
      throw new IllegalArgumentException("No such action for resource: " + name);
    }
    DynamicRecordMetadata returnsMetadata = _resourceSpec.getActionResponseMetadata(name);

    return buildRequestResponse(buildActionRequest(actionSchema, resourceLevel),
        buildActionResult(actionSchema),
        buildResourceMethodDescriptorForAction(name, returnsMetadata, resourceLevel));
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  private ActionRequest<?> buildActionRequest(ActionSchema action, ResourceLevel resourceLevel)
  {
    DynamicRecordMetadata requestParamsMetadata = _resourceSpec.getRequestMetadata(action.getName());
    DynamicRecordMetadata responseMetadata = _resourceSpec.getActionResponseMetadata(action.getName());

    TypeSpec<RecordTemplatePlaceholder> responseType = null;

    if (responseMetadata != null)
    {
      FieldDef<?> fieldDef = responseMetadata.getFieldDef("value");
      if (fieldDef != null && fieldDef.getDataClass() != null)
      {
        responseType = new TypeSpec<RecordTemplatePlaceholder>(
          (Class<RecordTemplatePlaceholder>)fieldDef.getDataClass(),
          responseMetadata.getRecordDataSchema());
      }
    }
    ActionRequestBuilder<Object, RecordTemplatePlaceholder> request =
        new ActionRequestBuilder<Object, RecordTemplatePlaceholder>(
          _uriTemplate,
View Full Code Here

    return request.build();
  }

  private ActionResult<?> buildActionResult(ActionSchema actionSchema)
  {
    DynamicRecordMetadata returnsMetadata = _resourceSpec.getActionResponseMetadata(actionSchema.getName());
    if (actionSchema.hasReturns())
    {
      FieldDef<?> fieldDef = returnsMetadata.getFieldDef("value");
      Object returnValue = generateFieldDefValue(fieldDef);
      return new ActionResult<Object>(returnValue);
    }
    else
    {
View Full Code Here

    Action response: "response", a String
     */
    ResourceMethod actionMethod = ResourceMethod.ACTION;
   
    FieldDef<String> actionParam = new FieldDef<String>("param", String.class, DataTemplateUtil.getSchema(String.class));
    DynamicRecordMetadata requestMetadata = new DynamicRecordMetadata("bar", Collections.singleton(actionParam));
    DataMap dataMap = new DataMap();
    dataMap.put("param", "paramValue");
    DynamicRecordTemplate input = new DynamicRecordTemplate(dataMap, requestMetadata.getRecordDataSchema());

    FieldDef<String> actionResponse =
        new FieldDef<String>("response", String.class, DataTemplateUtil.getSchema(String.class));
    DynamicRecordMetadata responseMetaData = new DynamicRecordMetadata("bar", Collections.singleton(actionResponse));
    ActionResponseDecoder<String> decoder =
        new ActionResponseDecoder<String>(actionResponse, responseMetaData.getRecordDataSchema());

    // new constructor

    ActionRequest<String> actionRequest1 =
        new ActionRequest<String>(input,
View Full Code Here

  @Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "action")
  public void testActionRequestBuilder(ProtocolVersion version, String expectedUri)
  {
    FieldDef<String> pParam = new FieldDef<String>("p", String.class, DataTemplateUtil.getSchema(String.class));
    Map<String, DynamicRecordMetadata> requestMetadataMap = new HashMap<String, DynamicRecordMetadata>();
    DynamicRecordMetadata requestMetadata = new DynamicRecordMetadata("action", Collections.<FieldDef<?>>singleton(pParam));
    requestMetadataMap.put("action", requestMetadata);
    DynamicRecordMetadata responseMetadata = new DynamicRecordMetadata("action", Collections.<FieldDef<?>>emptyList());
    Map<String, DynamicRecordMetadata> responseMetadataMap = new HashMap<String, DynamicRecordMetadata>();
    responseMetadataMap.put("action", responseMetadata);
    ResourceSpec resourceSpec = new ResourceSpecImpl(Collections.<ResourceMethod>emptySet(),
                                                     requestMetadataMap,
                                                     responseMetadataMap,
View Full Code Here

  public void testBuilderPathKeys1(ProtocolVersion version, String expectedUri)
  {
    List<FieldDef<?>> fieldDefs = new ArrayList<FieldDef<?>>();
    fieldDefs.add(new FieldDef<Integer>("key1", Integer.class, DataTemplateUtil.getSchema(Integer.class)));
    fieldDefs.add(new FieldDef<Integer>("key2", Integer.class, DataTemplateUtil.getSchema(Integer.class)));
    DynamicRecordMetadata requestMetadata = new DynamicRecordMetadata("action", fieldDefs);
    Map<String, DynamicRecordMetadata> requestMetadataMap = new HashMap<String, DynamicRecordMetadata>();
    requestMetadataMap.put("action", requestMetadata);
    DynamicRecordMetadata responseMetadata = new DynamicRecordMetadata("action", Collections.<FieldDef<?>>emptyList());
    Map<String, DynamicRecordMetadata> responseMetadataMap = new HashMap<String, DynamicRecordMetadata>();
    responseMetadataMap.put("action", responseMetadata);
    ResourceSpec resourceSpec = getResourceSpecForBuilderPathKeys();
    String[] expectedResourcePath = new String[] {"foo", "bar", "baz"};
View Full Code Here

  {
    List<FieldDef<?>> fieldDefs = new ArrayList<FieldDef<?>>();
    fieldDefs.add(new FieldDef<Integer>("key1", Integer.class, DataTemplateUtil.getSchema(
      Integer.class)));
    fieldDefs.add(new FieldDef<Integer>("key2", Integer.class, DataTemplateUtil.getSchema(Integer.class)));
    DynamicRecordMetadata requestMetadata = new DynamicRecordMetadata("action", fieldDefs);
    Map<String, DynamicRecordMetadata> requestMetadataMap = new HashMap<String, DynamicRecordMetadata>();
    requestMetadataMap.put("action", requestMetadata);
    DynamicRecordMetadata responseMetadata = new DynamicRecordMetadata("action", Collections.<FieldDef<?>>emptyList());
    Map<String, DynamicRecordMetadata> responseMetadataMap = new HashMap<String, DynamicRecordMetadata>();
    responseMetadataMap.put("action", responseMetadata);
    return new ResourceSpecImpl(Collections.<ResourceMethod>emptySet(), requestMetadataMap, responseMetadataMap);
  }
View Full Code Here

    else
    {
      response = Collections.emptyList();
    }
    return new ActionMetadata(action.getName(),
                              new DynamicRecordMetadata(action.getName(), fieldDefs),
                              new DynamicRecordMetadata(action.getName(), response));
  }
View Full Code Here

TOP

Related Classes of com.linkedin.data.template.DynamicRecordMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.