use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.
the class GobblinServiceManagerTest method testBadUpdate.
@Test
public void testBadUpdate() throws Exception {
Map<String, String> flowProperties = Maps.newHashMap();
flowProperties.put("param1", "value1b");
flowProperties.put("param2", "value2b");
FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_DUMMY_GROUP_NAME).setFlowName(TEST_DUMMY_FLOW_NAME)).setTemplateUris(TEST_TEMPLATE_URI).setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE)).setProperties(new StringMap(flowProperties));
try {
this.flowConfigClient.updateFlowConfig(flowConfig);
} catch (RestLiResponseException e) {
Assert.fail("Bad update should pass without complaining that the spec does not exists.");
}
cleanUpDir(FLOW_SPEC_STORE_DIR);
}
use of com.linkedin.restli.client.RestLiResponseException in project rest.li by linkedin.
the class TestNullGreetingsClient method sendUpdateAndAssert.
private void sendUpdateAndAssert(final RootBuilderWrapper<Long, Greeting> builders, Long id) throws RemoteInvocationException {
try {
final Greeting someGreeting = new Greeting().setMessage("Hello").setTone(Tone.INSULTING);
getClient().sendRequest(builders.update().id(id).input(someGreeting).build()).getResponse();
} catch (final RestLiResponseException responseException) {
assertCorrectInternalServerMessageForNull(responseException, "update");
}
}
use of com.linkedin.restli.client.RestLiResponseException in project rest.li by linkedin.
the class TestGroupsClient method testAssociationCreateGetDelete.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestMembershipsBuilderDataProvider")
public void testAssociationCreateGetDelete(ProtocolVersion version, RootBuilderWrapper<CompoundKey, GroupMembership> membershipBuilders) throws RemoteInvocationException {
// Setup - create group memberships
CompoundKey key1 = buildCompoundKey(1, 1);
GroupMembership groupMembership1 = buildGroupMembership(null, "alfred@test.linkedin.com", "Alfred", "Hitchcock");
Response<EmptyRecord> response = getClient().sendRequest(membershipBuilders.update().id(key1).input(groupMembership1).build()).getResponse();
Assert.assertEquals(response.getStatus(), 204);
// Get membership
Request<GroupMembership> getRequest = membershipBuilders.get().id(key1).fields(GroupMembership.fields().contactEmail()).build();
GroupMembership groupMembership = getClient().sendRequest(getRequest).getResponse().getEntity();
Assert.assertEquals(groupMembership.getContactEmail(), "alfred@test.linkedin.com");
// Delete the newly created group membership
Response<EmptyRecord> deleteResponse = getClient().sendRequest(membershipBuilders.delete().id(key1).build()).getResponse();
Assert.assertEquals(deleteResponse.getStatus(), 204);
// Make sure it is gone
try {
getClient().sendRequest(getRequest).getResponse();
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), 404);
}
}
use of com.linkedin.restli.client.RestLiResponseException in project rest.li by linkedin.
the class TestGroupsClient method testDefaultValue.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestGroupsBuilderDataProvider")
public void testDefaultValue(RootBuilderWrapper<Integer, Group> groupBuilders) throws RemoteInvocationException {
// use server side default value for the RecordTemplate
getClient().sendRequest(groupBuilders.findBy("ComplexCircuit").build()).getResponse();
try {
// specifying an instance of the RecordTemplate which mismatches the default will fail the request
final GroupMembershipParam newValue = new GroupMembershipParam();
newValue.setIntParameter(0);
newValue.setStringParameter("fail");
getClient().sendRequest(groupBuilders.findBy("ComplexCircuit").setQueryParam("record", newValue).build()).getResponse();
Assert.fail("Expect exception when specifying the \"record\" query parameter different from the default");
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), 500);
}
}
use of com.linkedin.restli.client.RestLiResponseException in project rest.li by linkedin.
the class TestMaxBatchSize method testBatchPartialUpdateWithMaxBatchSizeBeyondLimitation.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testBatchPartialUpdateWithMaxBatchSizeBeyondLimitation(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
Greeting patchedGreetingOne = new Greeting().setTone(Tone.INSULTING).setId(1l).setMessage("Hello");
Greeting patchedGreetingTwo = new Greeting().setTone(Tone.FRIENDLY).setId(2l).setMessage("Hi");
Greeting patchedGreetingThree = new Greeting().setTone(Tone.SINCERE).setId(3l).setMessage("Hello world");
Map<Long, PatchRequest<Greeting>> patchInputs = new HashMap<>();
patchInputs.put(1l, PatchGenerator.diff(GREETING_ONE, patchedGreetingOne));
patchInputs.put(2l, PatchGenerator.diff(GREETING_TWO, patchedGreetingTwo));
patchInputs.put(3l, PatchGenerator.diff(GREETING_THREE, patchedGreetingThree));
Request<BatchKVResponse<Long, UpdateStatus>> request = builders.batchPartialUpdate().patchInputs(patchInputs).build();
try {
getClient().sendRequest(request).getResponse();
Assert.fail("The batch size is larger than the allowed max batch size should cause an exception.");
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST.getCode());
Assert.assertEquals(e.getServiceErrorMessage(), "The request batch size: " + "3 is larger than the allowed max batch size: 2 for method: batch_partial_update");
}
}
Aggregations