Package com.alu.e3.prov.restapi.model

Examples of com.alu.e3.prov.restapi.model.BasicResponse


  @Ignore
  public void testDeleteUnknownApiID() throws Exception {
    String apiID = ""+System.currentTimeMillis();

    // Delete step
    BasicResponse response = given()
        .contentType("application/xml")
        .expect()
        .statusCode(500)
        .header("X-Application-Error-Code", equalTo("500"))
        .rootPath("response")
        .body("status", equalTo("FAILURE"))
        //.log().ifError()
        .when()
        .delete("/" + apiID)
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull(response);
    Assert.assertEquals("FAILURE", response.getStatus());

  }
View Full Code Here


    Api data = newApi();
    String apiID = ""+(new Random().nextLong());
    data.setId(apiID);

    // Create step
    BasicResponse response = given()
        .contentType("application/xml")
        .body(data, ObjectMapper.JAXB)
        .expect()
        .statusCode(200)
        .rootPath("response")
        .body("status", equalTo("SUCCESS"))
        .body("id", notNullValue())
        .log().ifError()
        .when()
        .post("")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    String apiIDReturned = response.getId();

    Assert.assertNotNull(response);
    Assert.assertNotNull(apiIDReturned);
    Assert.assertEquals(apiID, apiIDReturned);

    Assert.assertEquals("SUCCESS", response.getStatus());


    // Delete step
    @SuppressWarnings("unused")
    Response apiResponse = given()
View Full Code Here

    anotherDefaultContext.setId("test_anotherDefaultContext");
    anotherDefaultContext.setDefaultContext(true);
    data.getContexts().add(anotherDefaultContext);


    BasicResponse response = given()
        .contentType("application/xml")
        .body(data, ObjectMapper.JAXB)
        .expect()
        .statusCode(500)
        .rootPath("response")
        .body("status", equalTo("FAILURE"))
        .log().ifError()
        .when()
        .post("")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull(response);
    Assert.assertEquals("FAILURE", response.getStatus());
  }
View Full Code Here

    String apiID = ""+(new Random().nextLong());
    data.setId(apiID);

    // Create step
    BasicResponse response = given()
        .contentType("application/xml")
        .body(data, ObjectMapper.JAXB)
        .expect()
        .statusCode(200)
        .rootPath("response")
        .body("status", equalTo("SUCCESS"))
        .body("id", notNullValue())
        .log().ifError()
        .when()
        .post("")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    String apiIDReturned = response.getId();

    Assert.assertNotNull(response);
    Assert.assertNotNull(apiIDReturned);
    Assert.assertEquals(apiID, apiIDReturned);

    Assert.assertEquals("SUCCESS", response.getStatus());


    // Delete step
    BasicResponse apiResponse = given()
        .contentType("application/xml")
        .expect()
        .statusCode(200)
        .rootPath("response")
        .body("status", equalTo("SUCCESS"))
View Full Code Here

    newApi.setId(apiID);

    newApi.setNotificationFormat(NotificationFormat.HEADER);

    // Testing we can't have NotificationFormat tag on Non Notification type APIs
    BasicResponse response = given()
        .contentType("application/xml")
        .body(newApi, ObjectMapper.JAXB)
        .expect()
        .statusCode(500)
        //.rootPath("response")
        //.body("status", equalTo("SUCCESS"))
        //.body("id", notNullValue())
        .log().ifError()
        .when()
        .post("")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull("No error message", response.getError());
    Assert.assertNotNull("No error message", response.getError().getErrorText());
    Assert.assertTrue("Wrong errorMsg value", response.getError().getErrorText().contains("can't have NotificationFormat"));

    // Testing Wrong : Subscription + Notification Format
    newApi.setSubscriptionStep(SubscriptionStep.SUBSCRIPTION);
    response = given()
        .contentType("application/xml")
        .body(newApi, ObjectMapper.JAXB)
        .expect()
        .statusCode(500)
        //.rootPath("response")
        //.body("status", equalTo("SUCCESS"))
        //.body("id", notNullValue())
        .log().ifError()
        .when()
        .post("")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull("No error message", response.getError());
    Assert.assertNotNull("No error message", response.getError().getErrorText());
    Assert.assertTrue("Wrong errorMsg value", response.getError().getErrorText().contains("can't have a NotificationFormat in Subscription step mode"));

    // Testing Wrong : Notification + NotificationFormat + Target hosts
    newApi.setSubscriptionStep(SubscriptionStep.NOTIFICATION);

    response = given()
        .contentType("application/xml")
        .body(newApi, ObjectMapper.JAXB)
        .expect()
        .statusCode(500)
        //.rootPath("response")
        //.body("status", equalTo("SUCCESS"))
        //.body("id", notNullValue())
        .log().ifError()
        .when()
        .post("")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull("No error message", response.getError());
    Assert.assertNotNull("No error message", response.getError().getErrorText());
    Assert.assertTrue("Wrong errorMsg value", response.getError().getErrorText().contains("Notification step can't have any target host"));

    // Testing Wrong : Notification - NotificationFormat - TargetHost
    for (ApiContext apiCtx : newApi.getContexts())
      apiCtx.setTargetHosts(null);

    newApi.setNotificationFormat(null);

    response = given()
        .contentType("application/xml")
        .body(newApi, ObjectMapper.JAXB)
        .expect()
        .statusCode(500)
        //.rootPath("response")
        //.body("status", equalTo("SUCCESS"))
        //.body("id", notNullValue())
        .log().ifError()
        .when()
        .post("")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull("No error message", response.getError());
    Assert.assertNotNull("No error message", response.getError().getErrorText());
    Assert.assertTrue("Wrong errorMsg value", response.getError().getErrorText().contains("Notification must have a NotificationFormat"));

    // SUCCESS : Notification + NotificationFormat - TargetHost
    newApi.setNotificationFormat(NotificationFormat.HEADER);
    response = given()
        .contentType("application/xml")
View Full Code Here

  public void testCreateDeleteBulkBucket() throws Exception {
    String bucketId = "bucket_1";

    BulkPolicyQuotaRLBucketType bulk = newBulkProvision(bucketId);

    BasicResponse response = given().contentType("application/xml").body(bulk, ObjectMapper.JAXB).expect().statusCode(200).rootPath("response").body("status", equalTo("SUCCESS")).log().ifError()
        .when().post(baseBulkPath).andReturn().as(BasicResponse.class, ObjectMapper.JAXB);

    assertNotNull(response);
    assertEquals("SUCCESS", response.getStatus());
   
   
    bulk.getQuotaRLBucket().getAuthIds().add("a_3");
    bulk.getQuotaRLBucket().getAuthIds().add("a_4");
   
    // append
   
    response = given().contentType("application/xml").body(bulk, ObjectMapper.JAXB).expect().statusCode(500).rootPath("response").body("status", equalTo("FAILURE")).log().ifError()
    .when().put(baseBulkPath  + "/" + "wrongBucketID").andReturn().as(BasicResponse.class, ObjectMapper.JAXB);
   
    response = given().contentType("application/xml").body(bulk, ObjectMapper.JAXB).expect().statusCode(200).rootPath("response").body("status", equalTo("SUCCESS")).log().ifError()
    .when().put(baseBulkPath  + "/" + bulk.getQuotaRLBucket().getId()).andReturn().as(BasicResponse.class, ObjectMapper.JAXB);

    assertNotNull(response);
    assertEquals("SUCCESS", response.getStatus());
   
    // Delete step
    response = given().contentType("application/xml").body(bulk).expect().statusCode(200).rootPath("response").body("status", equalTo("SUCCESS")).log().ifError().when()
        .put(baseBulkPath + "/" + bulk.getQuotaRLBucket().getId() +"/deleteBucket").andReturn().as(BasicResponse.class, ObjectMapper.JAXB);

    assertNotNull(response);
    assertEquals("SUCCESS", response.getStatus());
  }
View Full Code Here

    context.setId("anid");
    context.setStatus(Status.ACTIVE);

    policy.getContexts().add(context);

    BasicResponse response = given().contentType("application/xml").body(policy, ObjectMapper.JAXB).expect().statusCode(200).rootPath("response").body("status", equalTo("SUCCESS")).log()
        .ifError().when().post(basePoliciesPath).andReturn().as(BasicResponse.class, ObjectMapper.JAXB);

    assertNotNull(response);
    assertEquals("SUCCESS", response.getStatus());

    if (id != null) {
      assertEquals(id, response.getId());
    } else {
      assertNotNull(response.getId());
      id = response.getId();
    }

  }
View Full Code Here

    }

  }

  private void deletePolicy(String id) {
    BasicResponse response = given().contentType("application/xml").expect().statusCode(200).rootPath("response").body("status", equalTo("SUCCESS")).log().ifError().when()
        .delete(basePoliciesPath + "/" + id).andReturn().as(BasicResponse.class, ObjectMapper.JAXB);

    assertNotNull(response);
    assertEquals("SUCCESS", response.getStatus());
  }
View Full Code Here

  public void createAuth(String id) throws Exception {

    Auth data = newAuthProvision(id);

    BasicResponse response = given()
    .contentType("application/xml")
    .body(data, ObjectMapper.JAXB)
    .expect()
    .statusCode(200).rootPath("response").body("status", equalTo("SUCCESS"))
    .log().ifError()
    .when().post(baseAuthPath)
    .andReturn().as(BasicResponse.class, ObjectMapper.JAXB);

    assertNotNull(response);
    assertEquals("SUCCESS", response.getStatus());

  }
View Full Code Here

    assertEquals("SUCCESS", response.getStatus());

  }

  private void deleteAuth(String id) {
    BasicResponse response = given().contentType("application/xml").expect().statusCode(200).rootPath("response").body("status", equalTo("SUCCESS")).log().ifError().when()
        .delete(baseAuthPath + "/" + id).andReturn().as(BasicResponse.class, ObjectMapper.JAXB);

    assertNotNull(response);
    assertEquals("SUCCESS", response.getStatus());

  }
View Full Code Here

TOP

Related Classes of com.alu.e3.prov.restapi.model.BasicResponse

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.