Search in sources :

Example 1 with SquashTMApi

use of com.seleniumtests.connectors.tms.squash.SquashTMApi 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)

Example 2 with SquashTMApi

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

the class TestSquashTMApi method testCreateUnexistingCampaign.

@Test(groups = { "ut" })
public void testCreateUnexistingCampaign() {
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    doReturn(Arrays.asList(campaign1, campaign2)).when(project1).getCampaigns();
    Campaign myCampaign = new Campaign("http://localhost:4321/campaigns/3", 3, "mycampaign");
    PowerMockito.when(Campaign.create(project1, "mycampaign", null)).thenReturn(myCampaign);
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
    Campaign newCampaign = api.createCampaign("mycampaign", null);
    Assert.assertEquals(newCampaign, myCampaign);
    // check campaign creation has been called
    PowerMockito.verifyStatic(Campaign.class);
    Campaign.create(project1, "mycampaign", null);
    // check no folder has been created
    PowerMockito.verifyStatic(CampaignFolder.class, never());
    CampaignFolder.create(eq(project1), any(), anyString());
}
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)

Example 3 with SquashTMApi

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

the class TestSquashTMApi method testServerInError2.

@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testServerInError2() {
    GetRequest getRequest = (GetRequest) createServerMock("GET", "/api/rest/latest/projects", 200, "{}");
    when(getRequest.asJson()).thenThrow(UnirestException.class);
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) GetRequest(kong.unirest.GetRequest) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with SquashTMApi

use of com.seleniumtests.connectors.tms.squash.SquashTMApi 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)

Example 5 with SquashTMApi

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

the class TestSquashTMApi method testDoNotCreateExistingCampaign.

/**
 * Check that we do not recreate a campaign if it already exist
 */
@Test(groups = { "ut" })
public void testDoNotCreateExistingCampaign() {
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    doReturn(Arrays.asList(campaign1, campaign2)).when(project1).getCampaigns();
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
    Campaign newCampaign = api.createCampaign("campaign1", "");
    Assert.assertEquals(newCampaign, campaign1);
    // check campaign creation has been called
    PowerMockito.verifyStatic(Campaign.class, never());
    Campaign.create(project1, "campaign1", null);
    // check no folder has been created
    PowerMockito.verifyStatic(CampaignFolder.class, never());
    CampaignFolder.create(eq(project1), any(), anyString());
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

SquashTMApi (com.seleniumtests.connectors.tms.squash.SquashTMApi)14 Test (org.testng.annotations.Test)14 ConnectorsTest (com.seleniumtests.ConnectorsTest)13 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)13 Campaign (com.seleniumtests.connectors.tms.squash.entities.Campaign)5 IterationTestPlanItem (com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem)4 TestCase (com.seleniumtests.connectors.tms.squash.entities.TestCase)3 Iteration (com.seleniumtests.connectors.tms.squash.entities.Iteration)2 GenericTest (com.seleniumtests.GenericTest)1 SquashTMConnector (com.seleniumtests.connectors.tms.squash.SquashTMConnector)1 ScenarioException (com.seleniumtests.customexception.ScenarioException)1 GetRequest (kong.unirest.GetRequest)1