Search in sources :

Example 6 with Iteration

use of com.seleniumtests.connectors.tms.squash.entities.Iteration in project seleniumRobot by bhecquet.

the class TestCampaign method testGetIterations.

@Test(groups = { "ut" })
public void testGetIterations() {
    createServerMock("GET", "/campaign/7/iterations", 200, "{" + "  \"_embedded\" : {" + "    \"iterations\" : [ {" + "      \"_type\" : \"iteration\"," + "      \"id\" : 10," + "      \"name\" : \"sample iteration 1\"," + "      \"reference\" : \"SAMP_IT_1\"," + "      \"description\" : \"<p>This iteration is a sample one...</p>\"," + "      \"parent\" : {" + "        \"_type\" : \"campaign\"," + "        \"id\" : 36," + "        \"name\" : \"sample parent campaign\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/36\"" + "          }" + "        }" + "      }," + "      \"created_by\" : \"User-1\"," + "      \"created_on\" : \"2017-07-21T10:00:00.000+0000\"," + "      \"last_modified_by\" : \"admin\"," + "      \"last_modified_on\" : \"2017-07-22T10:00:00.000+0000\"," + "      \"scheduled_start_date\" : null," + "      \"scheduled_end_date\" : null," + "      \"actual_start_date\" : \"2017-08-01T10:00:00.000+0000\"," + "      \"actual_end_date\" : \"2017-08-30T10:00:00.000+0000\"," + "      \"actual_start_auto\" : false," + "      \"actual_end_auto\" : false," + "      \"custom_fields\" : [ {" + "        \"code\" : \"CUF_Z\"," + "        \"label\" : \"Cuf Z\"," + "        \"value\" : \"value of Z\"" + "      }, {" + "        \"code\" : \"CUF_Y\"," + "        \"label\" : \"Cuf Y\"," + "        \"value\" : \"value of Y\"" + "      } ]," + "      \"test_suites\" : [ {" + "        \"_type\" : \"test-suite\"," + "        \"id\" : 88," + "        \"name\" : null," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/test-suites/88\"" + "          }" + "        }" + "      }, {" + "        \"_type\" : \"test-suite\"," + "        \"id\" : 11," + "        \"name\" : null," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/test-suites/11\"" + "          }" + "        }" + "      }, {" + "        \"_type\" : \"test-suite\"," + "        \"id\" : 14," + "        \"name\" : null," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/test-suites/14\"" + "          }" + "        }" + "      } ]," + "      \"attachments\" : [ ]," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/iterations/10\"" + "        }" + "      }" + "    } ]" + "  }," + "  \"_links\" : {" + "    \"first\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/36/iterations?page=0&size=1\"" + "    }," + "    \"prev\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/36/iterations?page=0&size=1\"" + "    }," + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/36/iterations?page=1&size=1\"" + "    }," + "    \"next\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/36/iterations?page=2&size=1\"" + "    }," + "    \"last\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/36/iterations?page=2&size=1\"" + "    }" + "  }," + "  \"page\" : {" + "    \"size\" : 1," + "    \"totalElements\" : 3," + "    \"totalPages\" : 3," + "    \"number\" : 1" + "  }" + "}");
    Campaign campaign = new Campaign("http://localhost:4321/campaign/7", 7, "campaign");
    List<Iteration> iterations = campaign.getIterations();
    Assert.assertEquals(iterations.size(), 1);
    Assert.assertEquals(iterations.get(0).getName(), "sample iteration 1");
    Assert.assertEquals(iterations.get(0).getId(), 10);
    Assert.assertEquals(iterations.get(0).getUrl(), "http://localhost:8080/api/rest/latest/iterations/10");
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with Iteration

use of com.seleniumtests.connectors.tms.squash.entities.Iteration in project seleniumRobot by bhecquet.

the class TestIteration method testGetAllTestCases.

@Test(groups = { "ut" })
public void testGetAllTestCases() {
    createServerMock("GET", "/iterations/1/test-plan", 200, "{" + "  \"_embedded\" : {" + "    \"test-plan\" : [ {" + "      \"_type\" : \"iteration-test-plan-item\"," + "      \"id\" : 4," + "      \"execution_status\" : \"READY\"," + "      \"referenced_test_case\" : {" + "        \"_type\" : \"test-case\"," + "        \"id\" : 8," + "        \"name\" : \"sample test case 8\"," + "        \"reference\" : \"TC-8\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/8\"" + "          }" + "        }" + "      }," + "      \"referenced_dataset\" : {" + "        \"_type\" : \"dataset\"," + "        \"id\" : 90," + "        \"name\" : \"sample dataset 90\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/datasets/90\"" + "          }" + "        }" + "      }," + "      \"last_executed_by\" : \"User-1\"," + "      \"last_executed_on\" : \"2017-06-25T10:00:00.000+0000\"," + "      \"assigned_to\" : \"User-1\"," + "      \"executions\" : [ {" + "        \"_type\" : \"execution\"," + "        \"id\" : 2," + "        \"execution_status\" : \"BLOCKED\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-24T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/2\"" + "          }" + "        }" + "      }, {" + "        \"_type\" : \"execution\"," + "        \"id\" : 3," + "        \"execution_status\" : \"SUCCESS\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-25T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/3\"" + "          }" + "        }" + "      } ]," + "      \"iteration\" : {" + "        \"_type\" : \"iteration\"," + "        \"id\" : 1," + "        \"name\" : \"sample iteration\"," + "        \"reference\" : \"IT1\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1\"" + "          }" + "        }" + "      }," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/4\"" + "        }" + "      }" + "    }, {" + "      \"_type\" : \"iteration-test-plan-item\"," + "      \"id\" : 12," + "      \"execution_status\" : \"READY\"," + "      \"referenced_test_case\" : {" + "        \"_type\" : \"test-case\"," + "        \"id\" : 16," + "        \"name\" : \"sample test case 16\"," + "        \"reference\" : \"TC-16\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/16\"" + "          }" + "        }" + "      }," + "      \"referenced_dataset\" : {" + "        \"_type\" : \"dataset\"," + "        \"id\" : 12," + "        \"name\" : \"sample dataset 12\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/datasets/12\"" + "          }" + "        }" + "      }," + "      \"last_executed_by\" : \"User-1\"," + "      \"last_executed_on\" : \"2017-06-28T10:00:00.000+0000\"," + "      \"assigned_to\" : \"User-1\"," + "      \"executions\" : [ {" + "        \"_type\" : \"execution\"," + "        \"id\" : 9," + "        \"execution_status\" : \"FAILURE\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-26T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/9\"" + "          }" + "        }" + "      }, {" + "        \"_type\" : \"execution\"," + "        \"id\" : 35," + "        \"execution_status\" : \"SUCCESS\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-28T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/35\"" + "          }" + "        }" + "      } ]," + "      \"iteration\" : {" + "        \"_type\" : \"iteration\"," + "        \"id\" : 1," + "        \"name\" : \"sample iteration\"," + "        \"reference\" : \"IT1\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1\"" + "          }" + "        }" + "      }," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/12\"" + "        }" + "      }" + "    } ]" + "  }," + "  \"_links\" : {" + "    \"first\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=0&size=2\"" + "    }," + "    \"prev\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=0&size=2\"" + "    }," + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=1&size=2\"" + "    }," + "    \"next\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=2&size=2\"" + "    }," + "    \"last\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=2&size=2\"" + "    }" + "  }," + "  \"page\" : {" + "    \"size\" : 2," + "    \"totalElements\" : 6," + "    \"totalPages\" : 3," + "    \"number\" : 1" + "  }" + "}");
    Iteration iteration = new Iteration("http://localhost:8080/api/rest/latest/iterations/1", 1, "my_iteration");
    List<IterationTestPlanItem> testCases = iteration.getAllTestCases();
    Assert.assertEquals(testCases.size(), 2);
    Assert.assertEquals(testCases.get(0).getTestCase().getId(), 8);
    Assert.assertEquals(testCases.get(0).getId(), 4);
    Assert.assertEquals(testCases.get(0).getUrl(), "http://localhost:8080/api/rest/latest/iteration-test-plan-items/4");
}
Also used : IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with Iteration

use of com.seleniumtests.connectors.tms.squash.entities.Iteration in project seleniumRobot by bhecquet.

the class TestIteration method testGetAllTestCaseWithError.

@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testGetAllTestCaseWithError() {
    GetRequest getRequest = (GetRequest) createServerMock("GET", "/iterations/1/test-plan", 200, "{}", "requestBodyEntity");
    when(getRequest.asPaged(any(), (Function<HttpResponse<JsonNode>, String>) any(Function.class))).thenThrow(UnirestException.class);
    Iteration iteration = new Iteration("http://localhost:8080/api/rest/latest/iterations/1", 1, "my_iteration");
    iteration.getAllTestCases();
}
Also used : GetRequest(kong.unirest.GetRequest) HttpResponse(kong.unirest.HttpResponse) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with Iteration

use of com.seleniumtests.connectors.tms.squash.entities.Iteration in project seleniumRobot by bhecquet.

the class TestIteration method testFromJson.

@Test(groups = { "ut" })
public void testFromJson() {
    JSONObject json = new JSONObject();
    json.put("_type", "iteration");
    json.put("id", 1);
    json.put("name", "foo");
    json.put("_links", new JSONObject("{\"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1\"" + "        }}"));
    Iteration iteration = Iteration.fromJson(json);
    Assert.assertEquals(iteration.getId(), 1);
    Assert.assertEquals(iteration.getName(), "foo");
    Assert.assertEquals(iteration.getUrl(), "http://localhost:8080/api/rest/latest/iterations/1");
}
Also used : JSONObject(kong.unirest.json.JSONObject) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with Iteration

use of com.seleniumtests.connectors.tms.squash.entities.Iteration in project seleniumRobot by bhecquet.

the class TestSquashTMApi method testCreateIteration.

@Test(groups = { "ut" })
public void testCreateIteration() {
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
    doReturn(Arrays.asList(iteration1, iteration2)).when(campaign1).getIterations();
    Iteration iteration3 = spy(new Iteration("http://localhost:4321/iterations/3", 3, "myIteration"));
    PowerMockito.when(Iteration.create(campaign1, "myIteration")).thenReturn(iteration3);
    Assert.assertEquals(api.createIteration(campaign1, "myIteration"), iteration3);
    // check campaign creation has been called
    PowerMockito.verifyStatic(Iteration.class);
    Iteration.create(campaign1, "myIteration");
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Iteration (com.seleniumtests.connectors.tms.squash.entities.Iteration)11 Test (org.testng.annotations.Test)10 ConnectorsTest (com.seleniumtests.ConnectorsTest)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 IterationTestPlanItem (com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem)5 Campaign (com.seleniumtests.connectors.tms.squash.entities.Campaign)4 SquashTMApi (com.seleniumtests.connectors.tms.squash.SquashTMApi)2 TestCase (com.seleniumtests.connectors.tms.squash.entities.TestCase)2 GetRequest (kong.unirest.GetRequest)2 HttpResponse (kong.unirest.HttpResponse)2 JSONObject (kong.unirest.json.JSONObject)2 GenericTest (com.seleniumtests.GenericTest)1 SquashTMConnector (com.seleniumtests.connectors.tms.squash.SquashTMConnector)1 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 HttpRequestWithBody (kong.unirest.HttpRequestWithBody)1 RequestBodyEntity (kong.unirest.RequestBodyEntity)1