use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.
the class FlowConfigTest method testCreateBadTemplateUri.
@Test
public void testCreateBadTemplateUri() throws Exception {
Map<String, String> flowProperties = Maps.newHashMap();
flowProperties.put("param1", "value1");
FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME)).setTemplateUris("FILE://bad/uri").setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE).setRunImmediately(true)).setProperties(new StringMap(flowProperties));
try {
_client.createFlowConfig(flowConfig);
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), HttpStatus.S_422_UNPROCESSABLE_ENTITY.getCode());
return;
}
Assert.fail("Get should have gotten a 422 error");
}
use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.
the class FlowConfigTest 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 {
_client.updateFlowConfig(flowConfig);
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), HttpStatus.S_404_NOT_FOUND.getCode());
return;
}
Assert.fail("Update should have raised a 404 error");
}
use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.
the class FlowConfigV2Test method testInvalidFlowId.
@Test
public void testInvalidFlowId() throws Exception {
Map<String, String> flowProperties = Maps.newHashMap();
flowProperties.put("param1", "value1");
StringBuilder sb1 = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
int maxFlowNameLength = ServiceConfigKeys.MAX_FLOW_NAME_LENGTH;
int maxFlowGroupLength = ServiceConfigKeys.MAX_FLOW_GROUP_LENGTH;
while (maxFlowGroupLength-- >= 0) {
sb1.append("A");
}
while (maxFlowNameLength-- >= 0) {
sb2.append("A");
}
String TOO_LONG_FLOW_GROUP = sb1.toString();
String TOO_LONG_FLOW_NAME = sb2.toString();
FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TOO_LONG_FLOW_GROUP).setFlowName(TOO_LONG_FLOW_NAME)).setTemplateUris(TEST_TEMPLATE_URI).setProperties(new StringMap(flowProperties));
try {
_client.createFlowConfig(flowConfig);
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), HttpStatus.ORDINAL_422_Unprocessable_Entity);
Assert.assertTrue(e.getMessage().contains("is out of range"));
return;
}
Assert.fail();
}
use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.
the class FlowConfigV2Test method testDisallowedRequester.
@Test
public void testDisallowedRequester() throws Exception {
try {
ServiceRequester testRequester = new ServiceRequester("testName", "testType", "testFrom");
_requesterService.setRequester(testRequester);
Map<String, String> flowProperties = Maps.newHashMap();
flowProperties.put("param1", "value1");
FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME_4)).setTemplateUris(TEST_TEMPLATE_URI).setProperties(new StringMap(flowProperties));
_client.createFlowConfig(flowConfig);
testRequester.setName("testName2");
_client.deleteFlowConfig(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME_4));
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), HttpStatus.ORDINAL_401_Unauthorized);
}
}
use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.
the class FlowConfigV2Test method testRequesterUpdateRejected.
@Test
public void testRequesterUpdateRejected() throws Exception {
_requesterService.setRequester(TEST_REQUESTER);
Map<String, String> flowProperties = Maps.newHashMap();
FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME_9)).setTemplateUris(TEST_TEMPLATE_URI).setProperties(new StringMap(flowProperties));
_client.createFlowConfig(flowConfig);
// Update should be rejected because testName is not allowed to update the owner to testName2
flowProperties.put(RequesterService.REQUESTER_LIST, RequesterService.serialize(Lists.newArrayList(TEST_REQUESTER2)));
flowConfig.setProperties(new StringMap(flowProperties));
try {
_client.updateFlowConfig(flowConfig);
Assert.fail("Expected update to be rejected");
} catch (RestLiResponseException e) {
Assert.assertEquals(e.getStatus(), HttpStatus.ORDINAL_401_Unauthorized);
}
}
Aggregations