Search in sources :

Example 11 with CompoundKey

use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.

the class TestAlbumEntryResource method testBadUpdatePhotoId.

@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);
}
Also used : AlbumEntry(com.linkedin.restli.example.AlbumEntry) CompoundKey(com.linkedin.restli.common.CompoundKey) Test(org.testng.annotations.Test)

Example 12 with CompoundKey

use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.

the class TestAlbumEntryResource method testBadUpdateAlbumId.

@Test(expectedExceptions = RestLiServiceException.class)
public void testBadUpdateAlbumId() {
    // album 100 doesn't exist
    CompoundKey key = new CompoundKey().append("photoId", 1L).append("albumId", 100L);
    AlbumEntry entry = new AlbumEntry().setAddTime(4);
    _entryRes.update(key, entry);
}
Also used : AlbumEntry(com.linkedin.restli.example.AlbumEntry) CompoundKey(com.linkedin.restli.common.CompoundKey) Test(org.testng.annotations.Test)

Example 13 with CompoundKey

use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.

the class TestAlbumEntryResource method makeData.

private void makeData() {
    _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) };
    for (int i = 0; i < _entries.length; i++) {
        final UpdateResponse uResp = _entryRes.update(_keys[i], _entries[i]);
        Assert.assertEquals(uResp.getStatus(), HttpStatus.S_204_NO_CONTENT);
    }
}
Also used : UpdateResponse(com.linkedin.restli.server.UpdateResponse) AlbumEntry(com.linkedin.restli.example.AlbumEntry) CompoundKey(com.linkedin.restli.common.CompoundKey)

Example 14 with CompoundKey

use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.

the class CustomTypesResource3 method batchUpdate.

@Override
public BatchUpdateResult<CompoundKey, Greeting> batchUpdate(BatchUpdateRequest<CompoundKey, Greeting> entities) {
    Set<CompoundKey> keys = entities.getData().keySet();
    Map<CompoundKey, UpdateResponse> responseMap = new HashMap<CompoundKey, UpdateResponse>();
    Map<CompoundKey, RestLiServiceException> errorMap = new HashMap<CompoundKey, RestLiServiceException>();
    for (CompoundKey key : keys) {
        responseMap.put(key, new UpdateResponse(HttpStatus.S_201_CREATED));
    }
    return new BatchUpdateResult<CompoundKey, Greeting>(responseMap);
}
Also used : UpdateResponse(com.linkedin.restli.server.UpdateResponse) RestLiServiceException(com.linkedin.restli.server.RestLiServiceException) BatchUpdateResult(com.linkedin.restli.server.BatchUpdateResult) CompoundKey(com.linkedin.restli.common.CompoundKey) HashMap(java.util.HashMap)

Example 15 with CompoundKey

use of com.linkedin.restli.common.CompoundKey in project rest.li by linkedin.

the class TestCustomTypesClient method testBatchUpdate.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request3BuilderDataProvider")
public void testBatchUpdate(RootBuilderWrapper<CompoundKey, Greeting> builders) throws RemoteInvocationException {
    Long lo = 5L;
    Long date = 13L;
    CustomTypes3Builders.Key key = new CustomTypes3Builders.Key().setLongId(new CustomLong(lo)).setDateId(new Date(date));
    RequestBuilder<? extends Request<BatchKVResponse<CompoundKey, UpdateStatus>>> batchUpdateRequest = builders.batchUpdate().input(key, new Greeting().setId(1).setMessage("foo")).getBuilder();
    BatchKVResponse<CompoundKey, UpdateStatus> response = getClient().sendRequest(batchUpdateRequest).getResponse().getEntity();
    Assert.assertEquals(response.getResults().keySet().size(), 1);
    CompoundKey expected = new CompoundKey();
    expected.append("dateId", new Date(date));
    expected.append("longId", new CustomLong(lo));
    Assert.assertEquals(response.getResults().keySet().iterator().next(), expected);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) CustomTypes3Builders(com.linkedin.restli.examples.greetings.client.CustomTypes3Builders) UpdateStatus(com.linkedin.restli.common.UpdateStatus) CompoundKey(com.linkedin.restli.common.CompoundKey) CustomNonNegativeLong(com.linkedin.restli.examples.custom.types.CustomNonNegativeLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CompoundKey(com.linkedin.restli.common.CompoundKey) Date(java.util.Date) BatchKVResponse(com.linkedin.restli.client.response.BatchKVResponse) Test(org.testng.annotations.Test)

Aggregations

CompoundKey (com.linkedin.restli.common.CompoundKey)94 Test (org.testng.annotations.Test)48 HashMap (java.util.HashMap)26 DataProvider (org.testng.annotations.DataProvider)20 ComplexResourceKey (com.linkedin.restli.common.ComplexResourceKey)17 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)16 GroupMembership (com.linkedin.restli.examples.groups.api.GroupMembership)15 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)14 AfterTest (org.testng.annotations.AfterTest)13 BeforeTest (org.testng.annotations.BeforeTest)13 DataMap (com.linkedin.data.DataMap)12 RestLiTestHelper.buildResourceModel (com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel)12 Key (com.linkedin.restli.server.Key)11 Followed (com.linkedin.restli.server.twitter.TwitterTestDataModels.Followed)10 HashSet (java.util.HashSet)10 BatchKVResponse (com.linkedin.restli.client.response.BatchKVResponse)9 TestRecord (com.linkedin.restli.client.test.TestRecord)9 BatchUpdateResult (com.linkedin.restli.server.BatchUpdateResult)9 AsyncFollowsAssociativeResource (com.linkedin.restli.server.twitter.AsyncFollowsAssociativeResource)9 EmptyRecord (com.linkedin.restli.common.EmptyRecord)8