Search in sources :

Example 1 with IterationTestPlanItem

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

the class TestIteration method testGetAllNoTestCases.

/**
 * Check case where no campaigns are available
 */
@Test(groups = { "ut" })
public void testGetAllNoTestCases() {
    createServerMock("GET", "/iterations/1/test-plan", 200, "{" + "  \"_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(), 0);
}
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 2 with IterationTestPlanItem

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

the class TestIterationTestPlanItem method testFromJson.

@Test(groups = { "ut" })
public void testFromJson() {
    JSONObject json = new JSONObject();
    json.put("_type", "iteration-test-plan-item");
    json.put("id", 6);
    json.put("name", "foo");
    json.put("_links", new JSONObject("{\"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/6\"" + "        }}"));
    json.put("referenced_test_case", new JSONObject("{" + "    \"_type\" : \"test-case\"," + "    \"id\" : 25," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/25\"" + "      }" + "    }" + "  }"));
    IterationTestPlanItem iteration = IterationTestPlanItem.fromJson(json);
    Assert.assertEquals(iteration.getId(), 6);
    Assert.assertEquals(iteration.getTestCase().getId(), 25);
    Assert.assertEquals(iteration.getUrl(), "http://localhost:8080/api/rest/latest/iteration-test-plan-items/6");
}
Also used : IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) JSONObject(kong.unirest.json.JSONObject) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with IterationTestPlanItem

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

the class TestIterationTestPlanItem method testAsJson.

@Test(groups = { "ut" })
public void testAsJson() {
    TestCase testCase = new TestCase(3, "http://localhost:8080/api/rest/latest/test-cases/3");
    IterationTestPlanItem itpi = new IterationTestPlanItem("http://localhost:8080/api/rest/latest/iteration-test-plan-items/6", 6, testCase);
    JSONObject json = itpi.asJson();
    Assert.assertEquals(json.getInt("id"), 6);
    Assert.assertEquals(json.getString("_type"), "iteration-test-plan-item");
}
Also used : IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) JSONObject(kong.unirest.json.JSONObject) TestCase(com.seleniumtests.connectors.tms.squash.entities.TestCase) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with IterationTestPlanItem

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

the class TestIterationTestPlanItem method testCreateIterationTestPlanItem.

@Test(groups = { "ut" })
public void testCreateIterationTestPlanItem() {
    HttpRequestWithBody postRequest = (HttpRequestWithBody) createServerMock("POST", "/iterations/4/test-plan", 200, "{" + "  \"_type\" : \"iteration-test-plan-item\"," + "  \"id\" : 38," + "  \"execution_status\" : \"READY\"," + "  \"referenced_test_case\" : {" + "    \"_type\" : \"test-case\"," + "    \"id\" : 25," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/25\"" + "      }" + "    }" + "  }," + "  \"referenced_dataset\" : {" + "    \"_type\" : \"dataset\"," + "    \"id\" : 3," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/datasets/3\"" + "      }" + "    }" + "  }," + "  \"last_executed_by\" : null," + "  \"last_executed_on\" : null," + "  \"assigned_to\" : \"User-1\"," + "  \"executions\" : [ ]," + "  \"iteration\" : {" + "    \"_type\" : \"iteration\"," + "    \"id\" : 4," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/iterations/4\"" + "      }" + "    }" + "  }," + "  \"_links\" : {" + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/38\"" + "    }," + "    \"project\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14\"" + "    }," + "    \"test-case\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/25\"" + "    }," + "    \"dataset\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/datasets/3\"" + "    }," + "    \"iteration\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/4\"" + "    }," + "    \"executions\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/38/executions\"" + "    }" + "  }" + "}", "request");
    Iteration iteration = new Iteration("http://localhost:8080/api/rest/latest/iterations/4", 4, "my_iteration");
    IterationTestPlanItem itpi = IterationTestPlanItem.create(iteration, new TestCase(25, "http://localhost:8080/api/rest/latest/test-cases/25"));
    verify(postRequest).body(new JSONObject("{\"_type\":\"iteration-test-plan-item\",\"test_case\":{\"id\":25,\"_type\":\"test-case\"}}"));
    Assert.assertEquals(itpi.getId(), 38);
}
Also used : IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) JSONObject(kong.unirest.json.JSONObject) TestCase(com.seleniumtests.connectors.tms.squash.entities.TestCase) HttpRequestWithBody(kong.unirest.HttpRequestWithBody) 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 5 with IterationTestPlanItem

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

the class TestSquashTMApi method testAddTestCaseInIteration.

@Test(groups = { "ut" })
public void testAddTestCaseInIteration() {
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
    doReturn(Arrays.asList(testPlanItem1, testPlanItem2)).when(iteration1).getAllTestCases();
    PowerMockito.when(TestCase.get(3)).thenReturn(testCase1);
    doReturn(testPlanItem1).when(iteration1).addTestCase(testCase1);
    IterationTestPlanItem itpi = api.addTestCaseInIteration(iteration1, 3);
    Assert.assertEquals(itpi, testPlanItem1);
    // check test case has been added
    verify(iteration1).addTestCase(any(TestCase.class));
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) TestCase(com.seleniumtests.connectors.tms.squash.entities.TestCase) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

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