Package com.linkedin.restli.common

Examples of com.linkedin.restli.common.CompoundKey


        return new ComplexResourceKey<RecordTemplatePlaceholder, RecordTemplatePlaceholder>(
            new RecordTemplatePlaceholder(keyData, keySchema),
            new RecordTemplatePlaceholder(paramsData, paramsSchema)
        );
      case COMPOUND:
        CompoundKey compoundKey = new CompoundKey();
        for (Map.Entry<String, CompoundKey.TypeInfo> keyPart : resourceSpec.getKeyParts().entrySet())
        {
          String key = keyPart.getKey();
          CompoundKey.TypeInfo typeInfo = keyPart.getValue();
          compoundKey.append(key, _dataGenerator.buildData(postfixBatchIdx(key, batchIdx),
                                                          typeInfo.getBinding().getSchema()));
        }
        return compoundKey;
      case PRIMITIVE:
        String keyName = resourceSchema.getCollection().getIdentifier().getName();
View Full Code Here


    compoundData.put("key1", "stringVal");
    compoundData.put("key2", 5);
    Map<String, CompoundKey.TypeInfo> fieldTypes = new HashMap<String, CompoundKey.TypeInfo>();
    fieldTypes.put("key1", new CompoundKey.TypeInfo(String.class, String.class));
    fieldTypes.put("key2", new CompoundKey.TypeInfo(Integer.class, Integer.class));
    CompoundKey compoundKey = CompoundKey.fromValues(compoundData, fieldTypes);
    String compoundKeyString = URIParamUtils.keyToString(compoundKey, NO_ESCAPING, null, true, version);
    Assert.assertEquals(compoundKeyString, expected);
  }
View Full Code Here

            _compoundResourceSpec,
            RestliRequestOptions.DEFAULT_OPTIONS);

    builder.ids(
        Arrays.asList(
            new CompoundKey().append("abc", 5)));

    builder.build();
  }
View Full Code Here

    GetRequestBuilder<CompoundKey, TestRecord> requestBuilder2 =
        new GetRequestBuilder<CompoundKey, TestRecord>("/",
                                 TestRecord.class,
                                 _compoundResourceSpec,
                                 RestliRequestOptions.DEFAULT_OPTIONS);
    CompoundKey key = new CompoundKey().append("abc", 1).append("def", 2);

    requestBuilder2.id(key);

    GetRequest<TestRecord> request2 = requestBuilder2.build();
View Full Code Here

      EasyMock.expect(((ActionRequest)mockRequest).getId()).andReturn(null);
      EasyMock.expect(mockRequest.getMethodName()).andReturn("testAction");
    }
    else if (method == ResourceMethod.FINDER)
    {
      EasyMock.expect(((FindRequest)mockRequest).getAssocKey()).andReturn(new CompoundKey());
      EasyMock.expect(mockRequest.getMethodName()).andReturn("testFinder");
    }
    else if (method == ResourceMethod.GET_ALL)
    {
      EasyMock.expect(((GetAllRequest)mockRequest).getAssocKey()).andReturn(new CompoundKey());
      EasyMock.expect(mockRequest.getMethodName()).andReturn(null);
    }
    else if (method == ResourceMethod.UPDATE)
    {
      EasyMock.expect(((UpdateRequest) mockRequest).getResourceSpec()).andReturn(new ResourceSpecImpl()).once();
View Full Code Here

    {
      _id = ((DeleteRequest) request).getId();
    }
    else if (request instanceof FindRequest)
    {
      final CompoundKey assocKey = ((FindRequest) request).getAssocKey();
      _id = assocKey.getNumParts() == 0 ? null : assocKey;
    }
    else if (request instanceof GetAllRequest)
    {
      final CompoundKey assocKey = ((GetAllRequest) request).getAssocKey();
      _id = assocKey.getNumParts() == 0 ? null : assocKey;
    }
    else
    {
      _id = null;
    }
View Full Code Here

                                                        queryParams1,
                                                        "bar",
                                                        BASE_URI_TEMPLATE,
                                                        Collections.<String, Object>emptyMap(),
                                                        RestliRequestOptions.DEFAULT_OPTIONS,
                                                        new CompoundKey().append("baz", "baz"));

    FindRequest<RecordTemplateWithPrimitiveKey> findRequest2 =
        new FindRequest<RecordTemplateWithPrimitiveKey>(Collections.<String, String>emptyMap(),
                                                        RecordTemplateWithPrimitiveKey.class,
                                                        buildResourceSpec(),
                                                        queryParams2,
                                                        "bar",
                                                        BASE_URI_TEMPLATE,
                                                        Collections.<String, Object>emptyMap(),
                                                        RestliRequestOptions.DEFAULT_OPTIONS,
                                                        new CompoundKey().append("baz", "baz"));

    data.add(Arrays.asList(findRequest1, findRequest2, true));

    Map<String, Object> queryParams3 = new HashMap<String, Object>(queryParams1);

    FindRequest<RecordTemplateWithPrimitiveKey> findRequest3 =
        new FindRequest<RecordTemplateWithPrimitiveKey>(Collections.<String, String>emptyMap(),
                                                        RecordTemplateWithPrimitiveKey.class,
                                                        buildResourceSpec(),
                                                        queryParams3,
                                                        "bar",
                                                        BASE_URI_TEMPLATE,
                                                        Collections.<String, Object>emptyMap(),
                                                        RestliRequestOptions.DEFAULT_OPTIONS,
                                                        new CompoundKey().append("baz", "BAZ"));

    data.add(Arrays.asList(findRequest1, findRequest3, false));

    // old constructor
View Full Code Here

  @Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "versions")
  public void testCompoundKeyMultipleEntities(ProtocolVersion version)
  {
    String key1 = "key1";
    String key2 = "key2";
    CompoundKey c1 = new CompoundKey().append(key1, 1L).append(key2, 2L);
    CompoundKey c2 = new CompoundKey().append(key1, 3L).append(key2, 4L);
    CompoundKey[] keys = {c1, c2};

    Map<String, CompoundKey.TypeInfo> fieldTypes = new HashMap<String, CompoundKey.TypeInfo>();
    fieldTypes.put(key1, new CompoundKey.TypeInfo(Long.class, Long.class));
    fieldTypes.put(key2, new CompoundKey.TypeInfo(Long.class, Long.class));
View Full Code Here

    _entries =
        new AlbumEntry[] { new AlbumEntry().setAddTime(1), new AlbumEntry().setAddTime(2),
            new AlbumEntry().setAddTime(3), new AlbumEntry().setAddTime(4),
            new AlbumEntry().setAddTime(5) };
    _keys =
        new CompoundKey[] { new CompoundKey().append("photoId", 1L).append("albumId", 1L),
            new CompoundKey().append("photoId", 2L).append("albumId", 1L),
            new CompoundKey().append("photoId", 3L).append("albumId", 1L),
            new CompoundKey().append("photoId", 1L).append("albumId", 2L),
            new CompoundKey().append("photoId", 4L).append("albumId", 2L) };

    // make some album entries

    for (int i = 0; i < _entries.length; i++)
    {
View Full Code Here

  @Test(expectedExceptions = RestLiServiceException.class)
  public void testBadUpdatePhotoId()
  {
    // photo 100 doesn't exist
    CompoundKey key = new CompoundKey().append("photoId", 100L).append("albumId", 1L);
    AlbumEntry entry = new AlbumEntry().setAddTime(4);
    _entryRes.update(key, entry);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.common.CompoundKey

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.