Package br.eti.kinoshita.testlinkjavaapi.model

Examples of br.eti.kinoshita.testlinkjavaapi.model.TestCase


     * @param map
     * @return Test Case.
     */
    @SuppressWarnings("unchecked")
    public static final TestCase getTestCase(Map<String, Object> map) {
        TestCase testCase = null;
        if (map != null && map.size() > 0) {
            // IMPORTANT: http://mantis.testlink.org/view.php?id=4784
            // Different methods to recover test cases use different parameter
            // names for the id, some uses "id" and others "testcase_id".
            Object o = map.get(TestLinkResponseParams.TEST_CASE_ID.toString());
            if (o == null) {
                o = map.get(TestLinkResponseParams.ID.toString());
            }

            if (o != null) {
                Integer id = Integer.parseInt(o.toString());

                if (id > 0) {
                    testCase = new TestCase();
                    testCase.setId(id);
                    testCase.setVersionId(getInteger(map, TestLinkResponseParams.TEST_CASE_VERSION_ID.toString()));
                    testCase.setVersion(getInteger(map, TestLinkResponseParams.VERSION.toString()));
                    testCase.setPreconditions(getString(map, TestLinkResponseParams.PRECONDITIONS.toString()));
                    testCase.setSummary(getString(map, TestLinkResponseParams.SUMMARY.toString()));
                    testCase.setParentId(getInteger(map, TestLinkResponseParams.PARENT_ID.toString()));
                    testCase.setOrder(getInteger(map, TestLinkResponseParams.ORDER.toString()));
                    testCase.setExecutionOrder(getInteger(map, TestLinkResponseParams.EXECUTION_ORDER.toString()));
                    // the name of the test case is not always in the same parameter
                    String testCaseName = getString(map, TestLinkResponseParams.TCASE_NAME.toString());
                    if (testCaseName == null) {
                        testCaseName = getString(map, TestLinkResponseParams.NAME.toString());
                    }
                    testCase.setName(testCaseName);

                    Platform platform = null;
                    String platformName = getString(map, TestLinkResponseParams.PLATFORM_NAME.toString());
                    Integer platformId = getInteger(map, TestLinkResponseParams.PLATFORM_ID.toString());
                    if (platformName != null || platformId != null) { // sometimes TL may return only one or the other
                        platform = new Platform();
                        platform.setId(platformId);
                        platform.setName(platformName);
                    }
                    testCase.setPlatform(platform);

                    testCase.setFeatureId(getInteger(map, TestLinkResponseParams.FEATURE_ID.toString()));

                    // IMPORTANT: the full external id (composed by
                    // prefix-external_id) come on
                    // different parameters depending of what methods was used.
                    //
                    // In 'getTestCase' -> 'full_tc_external_id'
                    // In 'getTestCasesForTestSuite' -> 'external_id'
                    // In 'getTestCasesForTestPlan' does not come (ToDo: add)
                    String fullExternalId = getString(map, TestLinkResponseParams.FULL_TEST_CASE_EXTERNAL_ID.toString());
                    if (fullExternalId == null) {
                        fullExternalId = getString(map, TestLinkResponseParams.FULL_TEST_CASE_EXTERNAL_ID2.toString());
                        if (fullExternalId == null) {
                            fullExternalId = getString(map, TestLinkResponseParams.EXTERNAL_ID.toString());
                        }
                    }
                    testCase.setFullExternalId(fullExternalId);

                    Integer executionTypeValue = getInteger(map, TestLinkResponseParams.EXECUTION_TYPE.toString());
                    ExecutionType execution = ExecutionType.getExecutionType(executionTypeValue);
                    testCase.setExecutionType(execution);
                    ExecutionStatus executionStatus = ExecutionStatus.NOT_RUN;
                    String executionStatusText = getString(map, TestLinkResponseParams.EXEC_STATUS.toString());
                    if (StringUtils.isNotBlank(executionStatusText)) {
                        executionStatus = ExecutionStatus.getExecutionStatus(executionStatusText.charAt(0));
                    }
                    testCase.setExecutionStatus(executionStatus);
                    testCase.setTestProjectId(getInteger(map, TestLinkParams.TEST_PROJECT_ID.toString()));
                    testCase.setTestSuiteId(getInteger(map, TestLinkParams.TEST_SUITE_ID2.toString()));
                    // inconsistent
                    // parameter
                    // name
                    // TODO: check if TL 2.0 allows it
                    // CustomField[] customFields = (CustomField[])getArray(map,
                    // TestLinkResponseParams.customFields.toString());
                    // if ( customFields != null )
                    // {
                    // for (int i = 0; i < customFields.length; i++)
                    // {
                    // CustomField customField = customFields[i];
                    // testCase.getCustomFields().add( customField );
                    // }
                    // }
                    Object[] stepsArray = (Object[]) getArray(map, TestLinkResponseParams.STEPS.toString());
                    if (stepsArray != null && stepsArray.length > 0) {
                        for (Object stepObject : stepsArray) {
                            Map<String, Object> stepMap = (Map<String, Object>) stepObject;
                            TestCaseStep step = Util.getTestCaseStep(stepMap);
                            testCase.getSteps().add(step);
                        }
                    }
                }

            }
View Full Code Here


    @Test(dataProvider = "testCaseData")
    public void testCreateTestCase(Integer testSuiteId, Integer testProjectId, String authorLogin, String summary,
            String preconditions) {
        this.loadXMLRPCMockData("tl.createTestCase.xml");

        TestCase testCase = null;

        try {
            testCase = api.createTestCase("Sample Test Case " + System.currentTimeMillis(), testSuiteId, testProjectId,
                    authorLogin, summary, null, preconditions, null, null, null, null, null, null);
        } catch (TestLinkAPIException e) {
            Assert.fail(e.getMessage(), e);
        }

        Assert.assertNotNull(testCase);

        Assert.assertTrue(testCase.getId() > 0);
    }
View Full Code Here

    @Test(dataProvider = "testCaseData")
    public void testGetTestCase(Integer testCaseId, Integer version) {
        this.loadXMLRPCMockData("tl.getTestCase.xml");

        TestCase testCase = null;

        try {
            testCase = this.api.getTestCase(testCaseId, null, version);
        } catch (TestLinkAPIException e) {
            Assert.fail(e.getMessage(), e);
        }

        Assert.assertNotNull(testCase);

        Assert.assertTrue(testCase.getId() > 0);

        Assert.assertNotNull(testCase.getSteps());
       
    }
View Full Code Here

     */
    protected TestCase createTestCase(String testCaseName, Integer testSuiteId, Integer testProjectId,
            String authorLogin, String summary, List<TestCaseStep> steps, String preconditions,
            TestImportance importance, ExecutionType execution, Integer order, Integer internalId,
            Boolean checkDuplicatedName, ActionOnDuplicate actionOnDuplicatedName) throws TestLinkAPIException {
        TestCase testCase = null;

        Integer id = null;

        testCase = new TestCase(id, testCaseName, testSuiteId, testProjectId, authorLogin, summary, steps,
                preconditions, importance, execution, null, order, internalId, null, checkDuplicatedName,
                actionOnDuplicatedName, null, null, null, null, null, null, null);

        try {
            Map<String, Object> executionData = Util.getTestCaseMap(testCase);
            Object response = this.executeXmlRpcCall(TestLinkMethods.CREATE_TEST_CASE.toString(), executionData);
            Object[] responseArray = Util.castToArray(response);
            Map<String, Object> responseMap = (Map<String, Object>) responseArray[0];

            id = Util.getInteger(responseMap, TestLinkResponseParams.ID.toString());
            testCase.setId(id);
        } catch (XmlRpcException xmlrpcex) {
            throw new TestLinkAPIException("Error creating test plan: " + xmlrpcex.getMessage(), xmlrpcex);
        }

        return testCase;
View Full Code Here

     * @return
     * @throws TestLinkAPIException
     */
    protected TestCase getTestCase(Integer testCaseId, Integer testCaseExternalId, Integer version)
            throws TestLinkAPIException {
        TestCase testCase = null;

        try {
            Map<String, Object> executionData = new HashMap<String, Object>();

            executionData.put(TestLinkParams.TEST_CASE_ID.toString(), testCaseId);
View Full Code Here

     * @return
     * @throws TestLinkAPIException
     */
    protected TestCase getTestCaseByExternalId(String fullTestCaseExternalId, Integer version)
            throws TestLinkAPIException {
        TestCase testCase = null;

        try {
            Map<String, Object> executionData = new HashMap<String, Object>();

            executionData.put(TestLinkParams.TEST_CASE_EXTERNAL_ID.toString(), fullTestCaseExternalId);
View Full Code Here

     * @param map
     * @return Test Case.
     */
    @SuppressWarnings("unchecked")
    public static final TestCase getTestCase(Map<String, Object> map) {
  TestCase testCase = null;
  if (map != null && map.size() > 0) {
      // IMPORTANT: http://mantis.testlink.org/view.php?id=4784
      // Different methods to recover test cases use different parameter
      // names for the id, some uses "id" and others "testcase_id".
      Object o = map.get(TestLinkResponseParams.TEST_CASE_ID.toString());
      if (o == null) {
    o = map.get(TestLinkResponseParams.ID.toString());
      }

      if (o != null) {
    Integer id = Integer.parseInt(o.toString());

    if (id > 0) {
        testCase = new TestCase();
        testCase.setId(id);
        testCase.setVersionId(getInteger(map,
          TestLinkResponseParams.TEST_CASE_VERSION_ID
            .toString()));
        testCase.setVersion(getInteger(map,
          TestLinkResponseParams.VERSION.toString()));
        testCase.setPreconditions(getString(map,
          TestLinkResponseParams.PRECONDITIONS.toString()));
        testCase.setSummary(getString(map,
          TestLinkResponseParams.SUMMARY.toString()));
        testCase.setParentId(getInteger(map,
          TestLinkResponseParams.PARENT_ID.toString()));
        testCase.setOrder(getInteger(map,
          TestLinkResponseParams.ORDER.toString()));
        testCase.setExecutionOrder(getInteger(map,
          TestLinkResponseParams.EXECUTION_ORDER.toString()));
        testCase.setName(getString(map,
          TestLinkResponseParams.NAME.toString()));

        // IMPORTANT: the full external id (composed by
        // prefix-external_id) come on
        // different parameters depending of what methods was used.
        //
        // In 'getTestCase' -> 'full_tc_external_id'
        // In 'getTestCasesForTestSuite' -> 'external_id'
        // In 'getTestCasesForTestPlan' does not come (ToDo: add)
        String fullExternalId = getString(map,
          TestLinkResponseParams.FULE__TEST_CASE_EXTERNAL_ID
            .toString());
        if (fullExternalId == null) {
      fullExternalId = getString(map,
        TestLinkResponseParams.EXTERNAL_ID.toString());
        }
        testCase.setFullExternalId(fullExternalId);

        Integer executionTypeValue = getInteger(map,
          TestLinkResponseParams.EXECUTION_TYPE.toString());
        ExecutionType execution = ExecutionType
          .getExecutionType(executionTypeValue);
        testCase.setExecutionType(execution);
        ExecutionStatus executionStatus = ExecutionStatus.NOT_RUN;
        String executionStatusText = getString(map,
          TestLinkResponseParams.EXEC_STATUS.toString());
        if (StringUtils.isNotBlank(executionStatusText)) {
      executionStatus = ExecutionStatus
        .getExecutionStatus(executionStatusText
          .charAt(0));
        }
        testCase.setExecutionStatus(executionStatus);
        testCase.setTestProjectId(getInteger(map,
          TestLinkParams.TEST_PROJECT_ID.toString()));
        testCase.setTestSuiteId(getInteger(map, "testsuite_id")); // TBD:
                        // inconsistent
                        // parameter
                        // name
        // TODO: check if TL 2.0 allows it
        // CustomField[] customFields = (CustomField[])getArray(map,
        // TestLinkResponseParams.customFields.toString());
        // if ( customFields != null )
        // {
        // for (int i = 0; i < customFields.length; i++)
        // {
        // CustomField customField = customFields[i];
        // testCase.getCustomFields().add( customField );
        // }
        // }
        Object[] stepsArray = (Object[]) getArray(map,
          TestLinkResponseParams.STEPS.toString());
        if (stepsArray != null && stepsArray.length > 0) {
      for (Object stepObject : stepsArray) {
          Map<String, Object> stepMap = (Map<String, Object>) stepObject;
          TestCaseStep step = Util.getTestCaseStep(stepMap);
          testCase.getSteps().add(step);
      }
        }
    }

      }
View Full Code Here

      Integer testProjectId, String authorLogin, String summary,
      List<TestCaseStep> steps, String preconditions,
      TestImportance importance, ExecutionType execution, Integer order,
      Integer internalId, Boolean checkDuplicatedName,
      ActionOnDuplicate actionOnDuplicatedName) throws TestLinkAPIException {
  TestCase testCase = null;

  Integer id = null;

  testCase = new TestCase(id, testCaseName, testSuiteId, testProjectId,
    authorLogin, summary, steps, preconditions, importance,
    execution, null, order, internalId, checkDuplicatedName,
    actionOnDuplicatedName, null, null, null, null, null);

  try {
      Map<String, Object> executionData = Util.getTestCaseMap(testCase);
      Object response = this.executeXmlRpcCall(
        TestLinkMethods.CREATE_TEST_CASE.toString(), executionData);
      Object[] responseArray = Util.castToArray(response);
      Map<String, Object> responseMap = (Map<String, Object>) responseArray[0];

      id = Util.getInteger(responseMap,
        TestLinkResponseParams.ID.toString());
      testCase.setId(id);
  } catch (XmlRpcException xmlrpcex) {
      throw new TestLinkAPIException("Error creating test plan: "
        + xmlrpcex.getMessage(), xmlrpcex);
  }
View Full Code Here

     * @throws TestLinkAPIException
     */
    protected TestCase getTestCase(Integer testCaseId,
      Integer testCaseExternalId, Integer version)
      throws TestLinkAPIException {
  TestCase testCase = null;

  try {
      Map<String, Object> executionData = new HashMap<String, Object>();

      executionData.put(TestLinkParams.TEST_CASE_ID.toString(), testCaseId);
View Full Code Here

     * @return
     * @throws TestLinkAPIException
     */
    protected TestCase getTestCaseByExternalId(String fullTestCaseExternalId,
      Integer version) throws TestLinkAPIException {
  TestCase testCase = null;

  try {
      Map<String, Object> executionData = new HashMap<String, Object>();

      executionData.put(TestLinkParams.TEST_CASE_EXTERNAL_ID.toString(),
View Full Code Here

TOP

Related Classes of br.eti.kinoshita.testlinkjavaapi.model.TestCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.