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

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




  @Test
  public void testDeploy() throws Exception {
    Api api = newApi();
    try {
      apiService.setDeploymentManager(new MockDeploymentManager.DeployOk());

      apiService.deployApi(api, ApiService.createExchange(api));
View Full Code Here


    }
  }

  @Test
  public void testRollback_DeployKo() throws Exception {
    Api api = newApi();
    try {
      // setup old jar in dataManager
      byte[] oldJar = new byte[] { 0, 1 };     
      ((DataManager) apiService.getDataManager()).deployApi(api.getId(), oldJar);

      // mock deploymentManager scenario
      apiService.setDeploymentManager(new MockDeploymentManager.DeployKO());

      ExchangeData exchange = ApiService.createExchange(api);
View Full Code Here

  }


  @Test
  public void testRollback_UndeployKo() throws Exception {
    Api api = newApi();
    try {
      // setup
      byte[] oldJar = new byte[] { 0, 1 };     
      ((DataManager) apiService.getDataManager()).deployApi(api.getId(), oldJar);

      apiService.setDeploymentManager(new MockDeploymentManager.FirstDeployKoSecondDeployOkUndeployKo());

      ExchangeData exchange = ApiService.createExchange(api);
      apiService.deployApi(api, exchange);
View Full Code Here

    }
  }

  @Test
  public void testRollback_FirstDeployOkSecondDeployKoUndeployOk() throws Exception {
    Api api = newApi();
    try {
      // setup
      byte[] oldJar = new byte[] { 0, 1 };     
      ((DataManager) apiService.getDataManager()).deployApi(api.getId(), oldJar);

      apiService.setDeploymentManager(new MockDeploymentManager.FirstDeployOkSecondDeployKoUndeployOk());

      ExchangeData exchange = ApiService.createExchange(api);
      apiService.deployApi(api, exchange);
View Full Code Here



  @Test
  public void testRollback_FirstDeployKoUndeployOk_NoOldJar() throws Exception {
    Api api = newApi();
    try {

      apiService.setDeploymentManager(new MockDeploymentManager.DeployKoUndeployKo());

      ExchangeData exchange = ApiService.createExchange(api);
View Full Code Here

    this.apiService = apiService;
  }

  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("AEndpointURL");

    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);
    httpsType.setTlsMode(com.alu.e3.prov.restapi.model.TLSMode.ONE_WAY);
    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

      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)
View Full Code Here

    }
  }

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

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

  @Test
  public void testCreateWithApiID() throws Exception {

    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()
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)
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.