Search in sources :

Example 81 with RestLiResponseException

use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.

the class GobblinServiceHATest method testBadUpdate.

@Test(dependsOnMethods = "testBadDelete")
public void testBadUpdate() throws Exception {
    logger.info("+++++++++++++++++++ testBadUpdate START");
    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_1).setFlowName(TEST_DUMMY_FLOW_NAME_1)).setTemplateUris(TEST_TEMPLATE_URI_1).setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE_1)).setProperties(new StringMap(flowProperties));
    try {
        this.node1FlowConfigClient.updateFlowConfig(flowConfig);
    } catch (RestLiResponseException e) {
        Assert.assertEquals(e.getStatus(), HttpStatus.NOT_FOUND_404);
    }
    try {
        this.node2FlowConfigClient.updateFlowConfig(flowConfig);
    } catch (RestLiResponseException e) {
        Assert.assertEquals(e.getStatus(), HttpStatus.NOT_FOUND_404);
    }
    logger.info("+++++++++++++++++++ testBadUpdate END");
}
Also used : FlowConfig(org.apache.gobblin.service.FlowConfig) FlowId(org.apache.gobblin.service.FlowId) StringMap(com.linkedin.data.template.StringMap) Schedule(org.apache.gobblin.service.Schedule) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Test(org.testng.annotations.Test)

Example 82 with RestLiResponseException

use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.

the class GobblinServiceManagerTest method testDelete.

@Test(dependsOnMethods = "testUpdate")
public void testDelete() throws Exception {
    FlowId flowId = new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME);
    URI uri = FlowSpec.Utils.createFlowSpecUri(flowId);
    // make sure flow config exists
    FlowConfig flowConfig = this.flowConfigClient.getFlowConfig(flowId);
    Assert.assertEquals(flowConfig.getId().getFlowGroup(), TEST_GROUP_NAME);
    Assert.assertEquals(flowConfig.getId().getFlowName(), TEST_FLOW_NAME);
    this.flowConfigClient.deleteFlowConfig(flowId);
    try {
        this.flowConfigClient.getFlowConfig(flowId);
    } catch (RestLiResponseException e) {
        Assert.assertEquals(e.getStatus(), HttpStatus.NOT_FOUND_404);
        Assert.assertFalse(this.gobblinServiceManager.getScheduler().getScheduledFlowSpecs().containsKey(uri.toString()));
        return;
    }
    Assert.fail("Get should have gotten a 404 error");
}
Also used : RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 83 with RestLiResponseException

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.assertEquals(e.getStatus(), HttpStatus.NOT_FOUND_404);
    }
}
Also used : StringMap(com.linkedin.data.template.StringMap) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Test(org.testng.annotations.Test)

Example 84 with RestLiResponseException

use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.

the class GobblinServiceHATest method testBadDelete.

@Test(dependsOnMethods = "testBadGet")
public void testBadDelete() throws Exception {
    logger.info("+++++++++++++++++++ testBadDelete START");
    FlowId flowId = new FlowId().setFlowGroup(TEST_DUMMY_GROUP_NAME_1).setFlowName(TEST_DUMMY_FLOW_NAME_1);
    try {
        this.node1FlowConfigClient.getFlowConfig(flowId);
        Assert.fail("Get should have raised a 404 error");
    } catch (RestLiResponseException e) {
        Assert.assertEquals(e.getStatus(), HttpStatus.NOT_FOUND_404);
    }
    try {
        this.node2FlowConfigClient.getFlowConfig(flowId);
        Assert.fail("Get should have raised a 404 error");
    } catch (RestLiResponseException e) {
        Assert.assertEquals(e.getStatus(), HttpStatus.NOT_FOUND_404);
    }
    logger.info("+++++++++++++++++++ testBadDelete END");
}
Also used : FlowId(org.apache.gobblin.service.FlowId) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Test(org.testng.annotations.Test)

Example 85 with RestLiResponseException

use of com.linkedin.restli.client.RestLiResponseException in project incubator-gobblin by apache.

the class FlowConfigTest method testCreateBadSchedule.

@Test
public void testCreateBadSchedule() 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(TEST_TEMPLATE_URI).setSchedule(new Schedule().setCronSchedule("bad 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");
}
Also used : StringMap(com.linkedin.data.template.StringMap) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Test(org.testng.annotations.Test)

Aggregations

RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)85 Test (org.testng.annotations.Test)75 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)30 StringMap (com.linkedin.data.template.StringMap)15 FlowId (org.apache.gobblin.service.FlowId)11 EmptyRecord (com.linkedin.restli.common.EmptyRecord)10 ValidationDemo (com.linkedin.restli.examples.greetings.api.ValidationDemo)10 ExecutionException (java.util.concurrent.ExecutionException)9 RestResponse (com.linkedin.r2.message.rest.RestResponse)7 FlowConfig (org.apache.gobblin.service.FlowConfig)7 RootBuilderWrapper (com.linkedin.restli.test.util.RootBuilderWrapper)6 ErrorResponse (com.linkedin.restli.common.ErrorResponse)5 HashMap (java.util.HashMap)5 Schedule (org.apache.gobblin.service.Schedule)5 RemoteInvocationException (com.linkedin.r2.RemoteInvocationException)4 MockRestliResponseExceptionBuilder (com.linkedin.restli.client.testutils.MockRestliResponseExceptionBuilder)4 CollectionResponse (com.linkedin.restli.common.CollectionResponse)4 AutoValidationWithProjectionBuilders (com.linkedin.restli.examples.greetings.client.AutoValidationWithProjectionBuilders)4 CreateGreeting (com.linkedin.restli.examples.greetings.client.CreateGreeting)4 PartialUpdateGreeting (com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting)4