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

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


   * TODO: Need to be check why.
   */
  @Test
  public void testCreateAndGetAllApi() {
    // GetAll step
    BasicResponse response = given()
        .contentType("application/xml")
        .expect()
        .statusCode(200)
        .rootPath("response")
        .body("status", equalTo("SUCCESS"))

        .log().ifError()
        .when()
        .get("/")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull(response);
    Assert.assertNotNull(response.getIds());
    for(String idToDelete : response.getIds()) {
      // Delete step
      BasicResponse deleteResponse = given()
          .contentType("application/xml")
          .expect()
          .statusCode(200)
          .rootPath("response")
          .body("status", equalTo("SUCCESS"))

          .log().ifError()
          .when()
          .delete("/" + idToDelete)
          .andReturn()
          .as(BasicResponse.class, ObjectMapper.JAXB);

      Assert.assertNotNull(deleteResponse);
      Assert.assertEquals("SUCCESS", deleteResponse.getStatus());
    }

    List<String> createdApis = new ArrayList<String>();

    Api data;
    for(int i=0; i<2; i++) {
      data = newApi();
      String apiID = ""+(new Random().nextLong());
      createdApis.add(apiID);
      data.setId(apiID);

      // Create step
      BasicResponse createResponse = 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 = createResponse.getId();

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

      Assert.assertEquals("SUCCESS", createResponse.getStatus());
    }


    // GetAll step
    BasicResponse getAllResponse = given()
        .contentType("application/xml")
        .expect()
        .statusCode(200)
        .rootPath("response")
        .body("status", equalTo("SUCCESS"))

        .log().ifError()
        .when()
        .get("/")
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull(getAllResponse);
    Assert.assertNotNull(getAllResponse.getIds());
    // sometimes other junits create apis
    Assert.assertTrue(createdApis.size() <= getAllResponse.getIds().size());
    for(int i=0; i<createdApis.size(); i++) {
      String idReturned = createdApis.get(i);
      Assert.assertTrue(getAllResponse.getIds().contains(idReturned));
    }
  }
View Full Code Here


  @Test
  public void testCreateWithNoApiID() throws Exception {
    Api data = newApi();

    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);

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

  }
View Full Code Here

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

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

    Assert.assertNotNull(response);
    Assert.assertNotNull(response.getId());
    Assert.assertEquals(apiID, response.getId());
    Assert.assertEquals("SUCCESS", response.getStatus());

  }
View Full Code Here

  @Test
  public void testCreateWithNoApiIDAndUpdate() throws Exception {
    Api data = newApi();
    data.setId(null);

    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);

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

    // do an update for this newly created API
    String createdApiId = response.getId();

    data.setId(createdApiId);
    data.setVersion("2.0");
    data.setEndpoint("newEndpointURL");


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

    Assert.assertNotNull(response);
    Assert.assertNotNull(response.getId());
    Assert.assertEquals("SUCCESS", response.getStatus());
    Assert.assertEquals(createdApiId, response.getId());


  }
View Full Code Here

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

    Api data = newApi();
    data.setId(apiID);

    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);

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

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

    // Add another with the same endpoint

    data.setId(new Random().nextLong()+"");
View Full Code Here

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

    Api data = newApi();
    data.setId(apiID);

    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);

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

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

    // Add another with the same endpoint

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

    Assert.assertNotNull(response);

    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);

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

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

  }
View Full Code Here

    Api data = newApi();
    data.setId(apiID);
    String origEndpoint = data.getEndpoint();

    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);

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

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

    // Add another with a different endpoint

    apiID = new Random().nextLong()+"";
    data.setId(apiID);
View Full Code Here

    Api data = newApi();
    data.setId(apiID);
    String origEndpoint = data.getEndpoint();

    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);

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

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

    // Delete
    response = given()
        .contentType("application/xml")
        .body(data, ObjectMapper.JAXB)
View Full Code Here

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

    Api data = newApi();
    data.setId(apiID);

    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);

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

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

    // do an update for this API ID

    data.setId(apiID);
    data.setVersion("2.0");

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

    Assert.assertNotNull(response);
    Assert.assertNotNull(response.getId());
    Assert.assertEquals("SUCCESS", response.getStatus());
    Assert.assertEquals(apiID, response.getId());


  }
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
    response = given()
        .contentType("application/xml")
        .expect()
        .statusCode(200)
        .rootPath("response")
        .body("status", equalTo("SUCCESS"))

        .log().ifError()
        .when()
        .delete("/" + apiID)
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull(response);
    Assert.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.