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


     */
    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

   * @return Test Case.
   */
  @SuppressWarnings("unchecked")
  public static final TestCase getTestCase(Map<String, Object> map)
  {
    TestCase testCase = null;
    if ( map != null && map.size() > 0 )
    {
      Object 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.testCaseVersionId.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.parentId.toString() ) );
          testCase.setOrder( getInteger(map, TestLinkResponseParams.order.toString() ) );
          testCase.setExecutionOrder( getInteger(map, TestLinkResponseParams.executionOrder.toString()));
          testCase.setName( getString(map, TestLinkResponseParams.name.toString()) );
           Integer executionTypeValue = getInteger( map, TestLinkResponseParams.executionType.toString() );
          ExecutionType execution = ExecutionType.getExecutionType( executionTypeValue );
          testCase.setExecutionType( execution );
          ExecutionStatus executionStatus = ExecutionStatus.NOT_RUN;
          String executionStatusText = getString(map, TestLinkResponseParams.execStatus.toString() );
          if ( StringUtils.isNotBlank(executionStatusText) )
          {
            executionStatus = ExecutionStatus.getExecutionStatus(executionStatusText.charAt(0));
          }
          testCase.setExecutionStatus(executionStatus);
          testCase.setTestProjectId(getInteger(map, TestLinkParams.testProjectId.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

    executionData.put("version", null);
    HashMap<String, Object> os = (HashMap<String, Object>) ((Object[])api.executeXmlRpcCall("tl.getTestCase", executionData))[0];
    System.out.println(((Object[])api.executeXmlRpcCall("tl.getTestCase", executionData))[0]);
    System.out.println("# STEP 0 : " + ((Object[])os.get("steps"))[0]);
   
    TestCase tc = api.getTestCase(3, null, null);
    System.out.println("# STEPS SIZE: " + tc.getSteps().size());
   
    System.out.println();
    executionData.clear();
    executionData.put("devKey", "9d7db1e2df412059fc14ffcf42d601f9");
    executionData.put("testplanid", 5);
View Full Code Here

   * @param map
   * @return
   */
  public static final TestCase getTestCase(Map<String, Object> map)
  {
    TestCase testCase = null;
    if ( map != null && map.size() > 0 )
    {
      Object 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.testCaseVersionId.toString()) );
          testCase.setPreconditions( getString(map, TestLinkResponseParams.preconditions.toString()));
          testCase.setSummary( getString(map, TestLinkResponseParams.summary.toString()) );
          testCase.setParentId( getInteger(map, TestLinkResponseParams.parentId.toString() ) );
          testCase.setOrder( getInteger(map, TestLinkResponseParams.order.toString() ) );
          testCase.setName( getString(map, TestLinkResponseParams.name.toString()));
          Integer executionTypeValue = getInteger(map, TestLinkResponseParams.executionType.toString());
          ExecutionType execution = ExecutionType.getExecutionType( executionTypeValue );
          testCase.setExecutionType( execution );
         
          // TODO: check if TL 2.0 allows it
//          CustomField[] customFields = (CustomField[])getArray(map, TestLinkResponseParams.customFields.toString());
//          if ( customFields != null )
//          {
View Full Code Here

      Integer internalId,
      Boolean checkDuplicatedName,
      String actionOnDuplicatedName)
  throws TestLinkAPIException
  {
    TestCase testCase = null;
   
    Integer id = null;
   
    testCase = new TestCase(
      id,
      testCaseName,
      testSuiteId,
      testProjectId,
      authorLogin,
      summary,
      steps,
      preconditions,
      importance,
      execution,
      order,
      internalId,
      checkDuplicatedName,
      actionOnDuplicatedName,
      null,
      null,
      null);
   
    try
    {
      Map<String, Object> executionData = Util.getTestCaseMap(testCase);
      Object response = this.executeXmlRpcCall(
          TestLinkMethods.createTestCase.toString(), executionData);
      Object[] responseArray = (Object[])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

  protected TestCase getTestCase(Integer testCaseId,
                   Integer testCaseExternalId,
                   Integer version)
  throws TestLinkAPIException
  {
    TestCase testCase = null;
   
    try
    {
      Map<String, Object> executionData = new HashMap<String, Object>();
     
View Full Code Here

   * @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.testCaseId.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.testCaseVersionId.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.parentId.toString() ) );
          testCase.setOrder( getInteger(map, TestLinkResponseParams.order.toString() ) );
          testCase.setExecutionOrder( getInteger(map, TestLinkResponseParams.executionOrder.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.fullTestCaseExternalId.toString());
          if (fullExternalId == null)
            fullExternalId = getString(map, TestLinkResponseParams.externalId.toString());
          testCase.setFullExternalId( fullExternalId );
         
           Integer executionTypeValue = getInteger( map, TestLinkResponseParams.executionType.toString() );
          ExecutionType execution = ExecutionType.getExecutionType( executionTypeValue );
          testCase.setExecutionType( execution );
          ExecutionStatus executionStatus = ExecutionStatus.NOT_RUN;
          String executionStatusText = getString(map, TestLinkResponseParams.execStatus.toString() );
          if ( StringUtils.isNotBlank(executionStatusText) )
          {
            executionStatus = ExecutionStatus.getExecutionStatus(executionStatusText.charAt(0));
          }
          testCase.setExecutionStatus(executionStatus);
          testCase.setTestProjectId(getInteger(map, TestLinkParams.testProjectId.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

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.