Search in sources :

Example 11 with Campaign

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

the class TestSquashTM method testCreateCampaign.

@Test(groups = "no-ti", enabled = false, attributes = { @CustomAttribute(name = "testId", values = "12") })
public void testCreateCampaign(ITestContext testContext) {
    SquashTMConnector tm = new SquashTMConnector("http://localhost:8080/squash", "admin", "admin", "Test Project-1");
    SquashTMApi api = tm.getApi();
    Campaign campaign = api.createCampaign("AutoTest", "SubFolder/foo");
    Iteration iteration = api.createIteration(campaign, "myiteration");
    IterationTestPlanItem tpi = api.addTestCaseInIteration(iteration, 239);
    api.setExecutionResult(tpi, ExecutionStatus.FAILURE);
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) SquashTMConnector(com.seleniumtests.connectors.tms.squash.SquashTMConnector) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 12 with Campaign

use of com.seleniumtests.connectors.tms.squash.entities.Campaign 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 13 with Campaign

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

the class TestIteration method testCreateIteration.

@Test(groups = { "ut" })
public void testCreateIteration() {
    HttpRequestWithBody postRequest = (HttpRequestWithBody) createServerMock("POST", "/campaigns/2/iterations", 200, "{" + "  \"_type\" : \"iteration\"," + "  \"id\" : 22," + "  \"name\" : \"new iteration\"," + "  \"reference\" : \"NEW_IT\"," + "  \"description\" : \"<p>A new iteration</p>\"," + "  \"parent\" : {" + "    \"_type\" : \"campaign\"," + "    \"id\" : 2," + "    \"name\" : \"parent campaign\"," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/2\"" + "      }" + "    }" + "  }," + "  \"created_by\" : \"User-A\"," + "  \"created_on\" : \"2017-04-07T10:00:00.000+0000\"," + "  \"last_modified_by\" : \"User-B\"," + "  \"last_modified_on\" : \"2017-04-15T10:00:00.000+0000\"," + "  \"scheduled_start_date\" : \"2017-04-09T10:00:00.000+0000\"," + "  \"scheduled_end_date\" : \"2017-04-14T10:00:00.000+0000\"," + "  \"actual_start_date\" : \"2017-04-10T10:00:00.000+0000\"," + "  \"actual_end_date\" : \"2017-04-15T10:00:00.000+0000\"," + "  \"actual_start_auto\" : false," + "  \"actual_end_auto\" : true," + "  \"custom_fields\" : [ {" + "    \"code\" : \"CUF\"," + "    \"label\" : \"cuf\"," + "    \"value\" : \"value\"" + "  } ]," + "  \"test_suites\" : [ ]," + "  \"attachments\" : [ ]," + "  \"_links\" : {" + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/22\"" + "    }," + "    \"project\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/4\"" + "    }," + "    \"campaign\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/2\"" + "    }," + "    \"test-suites\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/22/test-suites\"" + "    }," + "    \"test-plan\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/22/test-plan\"" + "    }," + "    \"attachments\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/22/attachments\"" + "    }" + "  }" + "}", "request");
    Campaign campaign = new Campaign("http://localhost:8080/api/rest/latest/campaigns/2", 2, "campaign");
    Iteration.create(campaign, "new iteration");
    verify(postRequest).body(new JSONObject("{\"_type\":\"iteration\",\"name\":\"new iteration\",\"parent\":{\"id\":2,\"_type\":\"campaign\"}}"));
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) JSONObject(kong.unirest.json.JSONObject) HttpRequestWithBody(kong.unirest.HttpRequestWithBody) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with Campaign

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

the class TestSquashTMConnector method testRecordResultTestWrongTestId.

/**
 * Check that if the testID is not valid, we raise an error
 * @param testContext
 */
@Test(groups = { "ut" })
public void testRecordResultTestWrongTestId(ITestContext testContext) {
    JSONObject connect = new JSONObject();
    connect.put(SquashTMConnector.TMS_SERVER_URL, "http://myServer");
    connect.put(SquashTMConnector.TMS_PROJECT, "project");
    connect.put(SquashTMConnector.TMS_USER, "user");
    connect.put(SquashTMConnector.TMS_PASSWORD, "password");
    SquashTMConnector squash = spy(new SquashTMConnector());
    squash.init(connect);
    doReturn(api).when(squash).getApi();
    CustomAttribute testIdAttr = new CustomAttribute() {

        @Override
        public Class<? extends Annotation> annotationType() {
            return null;
        }

        @Override
        public String[] values() {
            return new String[] { "1" };
        }

        @Override
        public String name() {
            return "testId";
        }
    };
    // customize test result so that it has attributes
    when(testResult.getMethod()).thenReturn(testMethod);
    when(testResult.isSuccess()).thenReturn(true);
    when(testResult.getName()).thenReturn("MyTest");
    when(testResult.getTestContext()).thenReturn(testContext);
    when(testResult.getParameters()).thenReturn(new Object[] {});
    when(testResult.getAttribute("testContext")).thenReturn(SeleniumTestsContextManager.getThreadContext());
    when(testMethod.getAttributes()).thenReturn(new CustomAttribute[] { testIdAttr });
    when(api.createCampaign(anyString(), anyString())).thenReturn(campaign);
    when(api.createIteration(any(Campaign.class), anyString())).thenReturn(iteration);
    when(api.addTestCaseInIteration(iteration, 1)).thenReturn(iterationTestPlanItem);
    squash.recordResult(testResult);
    // check we call all necessary API methods to record the result
    verify(api).createCampaign("Selenium " + testContext.getName(), "");
    verify(api).createIteration(campaign, SeleniumTestsContextManager.getThreadContext().getApplicationVersion());
    verify(api).addTestCaseInIteration(iteration, 1);
    verify(api).setExecutionResult(iterationTestPlanItem, ExecutionStatus.SUCCESS);
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) JSONObject(org.json.JSONObject) CustomAttribute(org.testng.annotations.CustomAttribute) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SquashTMConnector(com.seleniumtests.connectors.tms.squash.SquashTMConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest)

Example 15 with Campaign

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

the class TestSquashTMConnector method testRecordResultTestInSuccess.

@Test(groups = { "ut" })
public void testRecordResultTestInSuccess(ITestContext testContext) {
    JSONObject connect = new JSONObject();
    connect.put(SquashTMConnector.TMS_SERVER_URL, "http://myServer");
    connect.put(SquashTMConnector.TMS_PROJECT, "project");
    connect.put(SquashTMConnector.TMS_USER, "user");
    connect.put(SquashTMConnector.TMS_PASSWORD, "password");
    SquashTMConnector squash = spy(new SquashTMConnector());
    squash.init(connect);
    doReturn(api).when(squash).getApi();
    CustomAttribute testIdAttr = new CustomAttribute() {

        @Override
        public Class<? extends Annotation> annotationType() {
            return null;
        }

        @Override
        public String[] values() {
            return new String[] { "1" };
        }

        @Override
        public String name() {
            return "testId";
        }
    };
    // customize test result so that it has attributes
    when(testResult.getMethod()).thenReturn(testMethod);
    when(testResult.isSuccess()).thenReturn(true);
    when(testResult.getName()).thenReturn("MyTest");
    when(testResult.getTestContext()).thenReturn(testContext);
    when(testResult.getParameters()).thenReturn(new Object[] {});
    when(testResult.getAttribute("testContext")).thenReturn(SeleniumTestsContextManager.getThreadContext());
    when(testMethod.getAttributes()).thenReturn(new CustomAttribute[] { testIdAttr });
    when(api.createCampaign(anyString(), anyString())).thenReturn(campaign);
    when(api.createIteration(any(Campaign.class), anyString())).thenReturn(iteration);
    when(api.addTestCaseInIteration(iteration, 1)).thenReturn(iterationTestPlanItem);
    squash.recordResult(testResult);
    // check we call all necessary API methods to record the result
    verify(api).createCampaign("Selenium " + testContext.getName(), "");
    verify(api).createIteration(campaign, SeleniumTestsContextManager.getThreadContext().getApplicationVersion());
    verify(api).addTestCaseInIteration(iteration, 1);
    verify(api).setExecutionResult(iterationTestPlanItem, ExecutionStatus.SUCCESS);
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) JSONObject(org.json.JSONObject) CustomAttribute(org.testng.annotations.CustomAttribute) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SquashTMConnector(com.seleniumtests.connectors.tms.squash.SquashTMConnector) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

Campaign (com.seleniumtests.connectors.tms.squash.entities.Campaign)20 Test (org.testng.annotations.Test)18 ConnectorsTest (com.seleniumtests.ConnectorsTest)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 SquashTMConnector (com.seleniumtests.connectors.tms.squash.SquashTMConnector)7 MockitoTest (com.seleniumtests.MockitoTest)6 JSONObject (org.json.JSONObject)6 SquashTMApi (com.seleniumtests.connectors.tms.squash.SquashTMApi)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 CustomAttribute (org.testng.annotations.CustomAttribute)5 Iteration (com.seleniumtests.connectors.tms.squash.entities.Iteration)4 Project (com.seleniumtests.connectors.tms.squash.entities.Project)3 GetRequest (kong.unirest.GetRequest)3 IterationTestPlanItem (com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem)2 HttpResponse (kong.unirest.HttpResponse)2 JSONObject (kong.unirest.json.JSONObject)2 GenericTest (com.seleniumtests.GenericTest)1 CampaignFolder (com.seleniumtests.connectors.tms.squash.entities.CampaignFolder)1 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 ScenarioException (com.seleniumtests.customexception.ScenarioException)1