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

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


  @Test
  public void testCreateWithDuplicateEndpoint() throws Exception {
    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()+"");

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


   */
  @Test
  public void testCreateDeleteCreteDuplicateEndpoint() throws Exception {
    String apiID = ""+(new Random().nextLong());

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

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

  @Test
  public void testUpdateWithDuplicateEndpoint() throws Exception {
    String apiID = ""+(new Random().nextLong());

    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);
    data.setEndpoint(new Random().nextLong()+"");

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

    Assert.assertNotNull(response);

    data.setEndpoint(origEndpoint);
    response = given()
        .contentType("application/xml")
        .body(data, ObjectMapper.JAXB)
        .expect()
        .statusCode(500)
View Full Code Here

   */
  @Test
  public void testUpdateWithDeletedDuplicateEndpoint() throws Exception {
    String apiID = ""+(new Random().nextLong());

    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)
        .expect()
        .statusCode(200)
        .rootPath("response")
        .body("status", equalTo("SUCCESS"))
        .log().ifError()
        .when()
        .delete("/"+apiID)
        .andReturn()
        .as(BasicResponse.class, ObjectMapper.JAXB);

    Assert.assertNotNull(response);

    // Add another with a different endpoint

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

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

    Assert.assertNotNull(response);

    data.setEndpoint(origEndpoint);
    response = given()
        .contentType("application/xml")
        .body(data, ObjectMapper.JAXB)
        .expect()
        .statusCode(200)
View Full Code Here

  @Test
  public void testCreateWithApiIDAndUpdate() throws Exception {
    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()
View Full Code Here

  }

  @Test
  public void testCreateAndDelete() throws Exception {

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

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

  }


  private Api newApi() {

    Api api = new Api();


    ApiContext env = new ApiContext();
    env.setDefaultContext(true);
    env.setId("test");
    api.getContexts().add(env);

    env.setStatus(Status.ACTIVE);
    /*env.setMaxRateLimitTPMThreshold(1);
    env.setMaxRateLimitTPMWarning(1);
    env.setMaxRateLimitTPSThreshold(1);
    env.setMaxRateLimitTPSWarning(1);*/

    api.setId("getLocation" + (new Random().nextLong()));
    api.setDisplayName("test");
    api.setType(ApiType.PASS_THROUGH);
    api.setVersion("1.0");
    api.setEndpoint(new Random().nextLong()+"");

    api.setStatus(Status.ACTIVE);


    ProvisionAuthentication pauth = new ProvisionAuthentication();
    Authkey authKey = new Authkey(); authKey.setKeyName("key");
    pauth.setAuthKey(authKey);

    api.setAuthentication(pauth);

    pauth.getAuths().add(AuthType.AUTHKEY);
    pauth.getAuths().add(AuthType.BASIC);
    pauth.getAuths().add(AuthType.IP_WHITE_LIST);


    TargetHost th = new TargetHost();
    th.setUrl("http://www.yahoo.com");

    TargetHost th2 = new TargetHost();
    th2.setUrl("http://www.google.com");

    Authentication auth = new Authentication();
    auth.setType("NoAuth");
    Data d = new Data();
    Key k = new Key();
    k.setName("aKey00");
    k.setValue("key000Val");
    d.setKey(Arrays.asList(k));
    auth.setData(d);
    th.setAuthentication(auth);
    th2.setAuthentication(auth);

    env.setTargetHosts(Arrays.asList(th, th2));
    api.setTdrEnabled(new TdrEnabled());
    api.getTdrEnabled().setEnabled("true");

    HTTPSType httpsType = new HTTPSType();
    httpsType.setEnabled(true);
    api.setHttps(httpsType);

    TdrData tdrData = new TdrData();

    TdrType tdrType = new TdrType();
    tdrType.getType().add("apiRateLimit");

    DynamicTdr dt = new DynamicTdr();
    dt.setHttpHeaderName("HTTP_HEADER");
    dt.setTdrPropName("propname");
    dt.setTypes(tdrType);

    tdrData.getDynamic().add(dt);

    StaticTdr st = new StaticTdr();
    st.setValue("staticValue");
    st.setTdrPropName("staticName");

    st.setTypes(tdrType);

    tdrData.getStatic().add(st);
    api.setTdr(tdrData);


    return api;
  }
View Full Code Here

    return api;
  }

  @Test
  public void testCreateAndGetApi() {
    Api data = newApi();
    String apiID = ""+(new Random().nextLong());
    data.setId(apiID);

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

    //    Assert.assertNotNull(apiResponse.getApi().getType());
  }

  @Test
  public void testCreateMultipleDefaultContexts() throws Exception {
    Api data = newApi();
    ApiContext anotherDefaultContext = new ApiContext();
    anotherDefaultContext.setId("test_anotherDefaultContext");
    anotherDefaultContext.setDefaultContext(true);
    data.getContexts().add(anotherDefaultContext);


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

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

  @Test
  public void testCreateAndGetApiXmlValidation() {
    Api data = newApi();   

    Validation val = new Validation();
    data.setValidation(val);
    val.setXml(new Validation.Xml());
    //val.setSoap(new Validation.Soap(SoapVersionEnum.SOAP11));   
    //val.setSchema(new Validation.Schema(SchemaValidationEnum.WSDL, "hjhjsdhjsdhjsdh48647"));

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

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

TOP

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

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.