Search in sources :

Example 1 with Campaign

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

the class TestCampaign method testGetAllIterationsWithError.

@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testGetAllIterationsWithError() {
    GetRequest getRequest = (GetRequest) createServerMock("GET", "/campaign/7/iterations", 200, "{}", "requestBodyEntity");
    when(getRequest.asPaged(any(), (Function<HttpResponse<JsonNode>, String>) any(Function.class))).thenThrow(UnirestException.class);
    Campaign campaign = new Campaign("http://localhost:4321/campaign/7", 7, "campaign");
    List<Iteration> iterations = campaign.getIterations();
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) 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 2 with Campaign

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

the class TestCampaign method testFromJson.

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

Example 3 with Campaign

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

the class TestIteration method testCreateIterationWithError.

@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testCreateIterationWithError() {
    RequestBodyEntity postRequest = (RequestBodyEntity) createServerMock("POST", "/campaigns/2/iterations", 200, "{}", "requestBodyEntity");
    when(postRequest.asJson()).thenThrow(UnirestException.class);
    Campaign campaign = new Campaign("http://localhost:8080/api/rest/latest/campaigns/2", 2, "campaign");
    Iteration.create(campaign, "new iteration");
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) RequestBodyEntity(kong.unirest.RequestBodyEntity) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with Campaign

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

the class TestProject method testGetCampaignsInProject.

@Test(groups = { "ut" })
public void testGetCampaignsInProject() {
    GetRequest getRequest = (GetRequest) createServerMock("GET", "/projects/44/campaigns", 200, "{" + "  \"_embedded\" : {" + "    \"campaigns\" : [ {" + "      \"_type\" : \"campaign\"," + "      \"id\" : 255," + "      \"name\" : \"campaign 1\"," + "      \"reference\" : \"C-1\"," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/255\"" + "        }" + "      }" + "    }, {" + "      \"_type\" : \"campaign\"," + "      \"id\" : 122," + "      \"name\" : \"campaign 2\"," + "      \"reference\" : \"C-2\"," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/122\"" + "        }" + "      }" + "    }, {" + "      \"_type\" : \"campaign\"," + "      \"id\" : 147," + "      \"name\" : \"campaign 3\"," + "      \"reference\" : \"C-3\"," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/campaigns/147\"" + "        }" + "      }" + "    } ]" + "  }," + "  \"_links\" : {" + "    \"first\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=0&size=3&sort=name,desc\"" + "    }," + "    \"prev\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=1&size=3&sort=name,desc\"" + "    }," + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=2&size=3&sort=name,desc\"" + "    }," + "    \"next\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=3&size=3&sort=name,desc\"" + "    }," + "    \"last\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14/campaigns?page=3&size=3&sort=name,desc\"" + "    }" + "  }," + "  \"page\" : {" + "    \"size\" : 3," + "    \"totalElements\" : 10," + "    \"totalPages\" : 4," + "    \"number\" : 2" + "  }" + "}", "request");
    Project project = new Project("http://localhost:4321/projects/44", 44, "project");
    List<Campaign> campaigns = project.getCampaigns();
    Assert.assertEquals(campaigns.size(), 3);
    Assert.assertEquals(campaigns.get(0).getName(), "campaign 1");
    Assert.assertEquals(campaigns.get(0).getId(), 255);
}
Also used : Project(com.seleniumtests.connectors.tms.squash.entities.Project) Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) GetRequest(kong.unirest.GetRequest) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with Campaign

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

the class TestSquashTMApi method testCreateCampaignWithExistingFolder.

@Test(groups = { "ut" })
public void testCreateCampaignWithExistingFolder() {
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    doReturn(Arrays.asList(campaign1, campaign2)).when(project1).getCampaigns();
    PowerMockito.when(CampaignFolder.getAll()).thenReturn(Arrays.asList(campaignFolder1, campaignFolder2));
    Campaign myCampaign = new Campaign("http://localhost:4321/campaigns/3", 3, "mycampaign");
    PowerMockito.when(Campaign.create(project1, "mycampaign", campaignFolder2)).thenReturn(myCampaign);
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
    Campaign newCampaign = api.createCampaign("mycampaign", "campaignFolder1/campaignFolder2");
    Assert.assertEquals(newCampaign, myCampaign);
    // check campaign creation has been called
    PowerMockito.verifyStatic(Campaign.class);
    Campaign.create(project1, "mycampaign", campaignFolder2);
    // check the 2 folders has not been created
    PowerMockito.verifyStatic(CampaignFolder.class, never());
    CampaignFolder.create(eq(project1), any(), eq("campaignFolder1"));
    PowerMockito.verifyStatic(CampaignFolder.class, never());
    CampaignFolder.create(eq(project1), any(), eq("campaignFolder2"));
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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