com.qaprosoft.zafira.client.ZafiraClient类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(14.2k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中com.qaprosoft.zafira.client.ZafiraClient类的一些代码示例,展示了ZafiraClient类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZafiraClient类的具体详情如下:
包路径:com.qaprosoft.zafira.client.ZafiraClient
类名称:ZafiraClient

ZafiraClient介绍

暂无

代码示例

代码示例来源:origin: qaprosoft/zafira

@Override
public JobType register()
{
  this.jobType = zafiraClient.createJob(jobType).getObject();
  return this.jobType;
}

代码示例来源:origin: com.qaprosoft/zafira-client

/**
 * Registers test case in Zafira, it may be a new one or existing returned by service. 
 * 
 * @param suiteId - test suite id
 * @param primaryOwnerId - primary owner user id
 * @param secondaryOwnerId - secondary owner user id
 * @param testClass - test class name
 * @param testMethod - test method name
 * @return registered test case
 */
public TestCaseType registerTestCase(Long suiteId, Long primaryOwnerId, Long secondaryOwnerId, String testClass, String testMethod) 
{
  TestCaseType testCase = new TestCaseType(testClass, testMethod, "", suiteId, primaryOwnerId, secondaryOwnerId);
  String testCaseDetails = "testClass: %s, testMethod: %s, info: %s, testSuiteId: %d, primaryOwnerId: %d, secondaryOwnerId: %d";
  LOGGER.debug("Test Case details for registration:" + String.format(testCaseDetails, testClass, testMethod, "", suiteId, primaryOwnerId, secondaryOwnerId));
  Response<TestCaseType> response = createTestCase(testCase);
  testCase = response.getObject();
  if (testCase == null) 
  {
    throw new RuntimeException("Unable to register test case '"
        + String.format(testCaseDetails, testClass, testMethod, "", suiteId, primaryOwnerId) + "' for zafira service: " + serviceURL);
  } 
  else 
  {
    LOGGER.debug("Registered test case details:" + String.format(testCaseDetails, testClass, testMethod, "", suiteId, primaryOwnerId, secondaryOwnerId));
  }
  return testCase;
}

代码示例来源:origin: qaprosoft/zafira

@Override
public TestSuiteType register()
{
  this.testSuiteType = zafiraClient.createTestSuite(this.testSuiteType).getObject();
  return this.testSuiteType;
}

代码示例来源:origin: com.qaprosoft/zafira-client

/**
 * Finalizes test run calculating test results.
 * 
 * @param testRun - test run object
 * @return updated test run
 */
public TestRunType registerTestRunResults(TestRunType testRun)
{
  updateTestRun(testRun); 
  Response<TestRunType> response = finishTestRun(testRun.getId());
  return response.getObject();
}

代码示例来源:origin: com.qaprosoft/zafira-client

zc.initProject(!StringUtils.isEmpty(project) ? project : ZAFIRA_PROJECT);
this.user = zc.getUserProfile().getObject();
UserType suiteOwner =  zc.getUserOrAnonymousIfNotFound(configurator.getOwner(suiteContext));
this.suite = zc.registerTestSuite(suiteContext.getName(), FilenameUtils.getName(suiteContext.getXmlSuite().getFileName()), suiteOwner.getId());
this.job = zc.registerJob(ci.getCiUrl(), suiteOwner.getId());
  anonymous = zc.getUserOrAnonymousIfNotFound(ZafiraClient.DEFAULT_USER);
  parentJob = zc.registerJob(ci.getCiParentUrl(), anonymous.getId());
  Response<TestRunType> response = zc.getTestRunByCiRunId(ci.getCiRunId());
  this.run = response.getObject();
  Response<TestRunType> response = zc.startTestRun(this.run);
  this.run = response.getObject();
  List<TestType> testRunResults = Arrays.asList(zc.getTestRunResults(run.getId()).getObject());
  for (TestType test : testRunResults)
      this.run = zc.registerTestRunUPSTREAM_JOB(suite.getId(), convertToXML(configurator.getConfiguration()), job.getId(), parentJob.getId(), ci, Initiator.UPSTREAM_JOB, JIRA_SUITE_ID);
      break;
    case TIMERTRIGGER:
    case SCMTRIGGER:
      this.run = zc.registerTestRunBySCHEDULER(suite.getId(), convertToXML(configurator.getConfiguration()), job.getId(), ci, Initiator.SCHEDULER, JIRA_SUITE_ID);
      break;
    case MANUALTRIGGER:
      this.run = zc.registerTestRunByHUMAN(suite.getId(), user.getId(), convertToXML(configurator.getConfiguration()), job.getId(), ci, Initiator.HUMAN, JIRA_SUITE_ID);

代码示例来源:origin: com.qaprosoft/zafira-client

ZafiraSingleton() {
  try {
    CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
    config.setThrowExceptionOnMissing(false);
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(
        new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
            .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES))
            .getConfiguration());
    final boolean enabled = config.getBoolean("zafira_enabled", false);
    final String url = config.getString("zafira_service_url", StringUtils.EMPTY);
    final String token = config.getString("zafira_access_token", StringUtils.EMPTY);
    zc = new ZafiraClient(url);
    if (enabled && zc.isAvailable()) {
      Response<AuthTokenType> auth = zc.refreshToken(token);
      if (auth.getStatus() == 200) {
        zc.setAuthToken(auth.getObject().getType() + " " + auth.getObject().getAccessToken());
        this.running = true;
        this.zc.initAmazonS3Client();
        this.zc.initTenant();
      }
    }
  } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
}

代码示例来源:origin: com.qaprosoft/zafira-client

UserType primaryOwner = zc.getUserOrAnonymousIfNotFound(primaryOwnerName);
  LOGGER.debug("primaryOwner: " + primaryOwnerName);
  if(!StringUtils.isEmpty(secondaryOwnerName))
    secondaryOwner = zc.getUserOrAnonymousIfNotFound(secondaryOwnerName);
    LOGGER.debug("secondaryOwner: " + secondaryOwnerName);
  TestCaseType testCase = zc.registerTestCase(this.suite.getId(), primaryOwner.getId(),  (secondaryOwner != null ? secondaryOwner.getId() : null), testClass, testMethod);
  String testArgs = result.getParameters().toString();
  test = zc.registerTestStart(testName, group, Status.SKIPPED, testArgs, run.getId(), testCase.getId(), configurator.getRunCount(result), convertToXML(configurator.getConfiguration()), dependsOnMethods, getThreadCiTestId(), configurator.getTestTags(result));
  threadTest.set(test);
Response<TestType> rs = zc.finishTest(populateTestResult(result, Status.SKIPPED, getFullStackTrace(result)));
if(rs.getStatus() != 200 && rs.getObject() == null)

代码示例来源:origin: com.qaprosoft/zafira-client

zc = new ZafiraClient(ZAFIRA_URL);
ZAFIRA_ENABLED =  zc.isAvailable();
  Response<AuthTokenType> auth = zc.refreshToken(ZAFIRA_ACCESS_TOKEN);
  if(auth.getStatus() == 200)
    zc.setAuthToken(auth.getObject().getType() + " " + auth.getObject().getAccessToken());

代码示例来源:origin: qaprosoft/zafira

@Override
public TestRunType register()
{
  this.testRunType.setTestSuiteId(this.testSuiteTypeBuilder.getCurrentInstance().getId());
  this.testRunType.setJobId(this.jobTypeBuilder.getCurrentInstance().getId());
  this.testRunType = zafiraClient.startTestRun(this.testRunType).getObject();
  return this.testRunType;
}

代码示例来源:origin: com.qaprosoft/zafira-client

@Override
public void onTestSuccess(ITestResult result)
{
  if(!ZAFIRA_ENABLED) return;
  try 
  {
    Response<TestType> rs = zc.finishTest(populateTestResult(result, Status.PASSED, getFullStackTrace(result)));
    if(rs.getStatus() != 200 && rs.getObject() == null)
    {
      throw new RuntimeException("Unable to register test " + rs.getObject().getName() + " for zafira service: " + ZAFIRA_URL);
    }
  } 
  catch (Throwable e) {
    LOGGER.error("Undefined error during test case/method finish!", e);
  }
}

代码示例来源:origin: qaprosoft/zafira

/**
 * Registers test re-run in Zafira.
 * 
 * @param test - test object
 * @return registered test
 */
public TestType registerTestRestart(TestType test) 
{
  String testName = test.getName();
  Response<TestType> response = startTest(test);
  test = response.getObject();
  if (test == null) 
  {
    throw new RuntimeException("Unable to register test '" + testName + "' restart for zafira service: " + serviceURL);
  } 
  else 
  {
    LOGGER.debug("Registered test restart details:'" + testName + "'; startTime: " + new Date(test.getStartTime()));
  }
  return test;
}

代码示例来源:origin: qaprosoft/zafira

@Override
  public void run() 
  {
    if(testRun != null)
    {
      boolean aborted = zc.abortTestRun(testRun.getId());
      LOGGER.info("TestRunShutdownHook was executed with result: " + aborted);
    }
  }
}

代码示例来源:origin: qaprosoft/zafira

zc.initProject(!StringUtils.isEmpty(project) ? project : ZAFIRA_PROJECT);
this.user = zc.getUserProfile().getObject();
UserType suiteOwner =  zc.getUserOrAnonymousIfNotFound(configurator.getOwner(suiteContext));
this.suite = zc.registerTestSuite(suiteContext.getName(), FilenameUtils.getName(suiteContext.getXmlSuite().getFileName()), suiteOwner.getId());
this.job = zc.registerJob(ci.getCiUrl(), suiteOwner.getId());
  anonymous = zc.getUserOrAnonymousIfNotFound(ZafiraClient.DEFAULT_USER);
  parentJob = zc.registerJob(ci.getCiParentUrl(), anonymous.getId());
  Response<TestRunType> response = zc.getTestRunByCiRunId(ci.getCiRunId());
  this.run = response.getObject();
  Response<TestRunType> response = zc.startTestRun(this.run);
  this.run = response.getObject();
  List<TestType> testRunResults = Arrays.asList(zc.getTestRunResults(run.getId()).getObject());
  for (TestType test : testRunResults)
      this.run = zc.registerTestRunUPSTREAM_JOB(suite.getId(), convertToXML(configurator.getConfiguration()), job.getId(), parentJob.getId(), ci, Initiator.UPSTREAM_JOB, JIRA_SUITE_ID);
      break;
    case TIMERTRIGGER:
    case SCMTRIGGER:
      this.run = zc.registerTestRunBySCHEDULER(suite.getId(), convertToXML(configurator.getConfiguration()), job.getId(), ci, Initiator.SCHEDULER, JIRA_SUITE_ID);
      break;
    case MANUALTRIGGER:
      this.run = zc.registerTestRunByHUMAN(suite.getId(), user.getId(), convertToXML(configurator.getConfiguration()), job.getId(), ci, Initiator.HUMAN, JIRA_SUITE_ID);

代码示例来源:origin: qaprosoft/zafira

ZafiraSingleton() {
  try {
    CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
    config.setThrowExceptionOnMissing(false);
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(
        new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
            .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES))
            .getConfiguration());
    final boolean enabled = config.getBoolean("zafira_enabled", false);
    final String url = config.getString("zafira_service_url", StringUtils.EMPTY);
    final String token = config.getString("zafira_access_token", StringUtils.EMPTY);
    zc = new ZafiraClient(url);
    if (enabled && zc.isAvailable()) {
      Response<AuthTokenType> auth = zc.refreshToken(token);
      if (auth.getStatus() == 200) {
        zc.setAuthToken(auth.getObject().getType() + " " + auth.getObject().getAccessToken());
        this.running = true;
        this.zc.initAmazonS3Client();
        this.zc.initTenant();
      }
    }
  } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
}

代码示例来源:origin: qaprosoft/zafira

UserType primaryOwner = zc.getUserOrAnonymousIfNotFound(primaryOwnerName);
  LOGGER.debug("primaryOwner: " + primaryOwnerName);
  if(!StringUtils.isEmpty(secondaryOwnerName))
    secondaryOwner = zc.getUserOrAnonymousIfNotFound(secondaryOwnerName);
    LOGGER.debug("secondaryOwner: " + secondaryOwnerName);
  TestCaseType testCase = zc.registerTestCase(this.suite.getId(), primaryOwner.getId(),  (secondaryOwner != null ? secondaryOwner.getId() : null), testClass, testMethod);
  String testArgs = result.getParameters().toString();
  test = zc.registerTestStart(testName, group, Status.SKIPPED, testArgs, run.getId(), testCase.getId(), configurator.getRunCount(result), convertToXML(configurator.getConfiguration()), dependsOnMethods, getThreadCiTestId(), configurator.getTestTags(result));
  threadTest.set(test);
Response<TestType> rs = zc.finishTest(populateTestResult(result, Status.SKIPPED, getFullStackTrace(result)));
if(rs.getStatus() != 200 && rs.getObject() == null)

代码示例来源:origin: qaprosoft/zafira

/**
 * Finalizes test run calculating test results.
 * 
 * @param testRun - test run object
 * @return updated test run
 */
public TestRunType registerTestRunResults(TestRunType testRun)
{
  updateTestRun(testRun); 
  Response<TestRunType> response = finishTestRun(testRun.getId());
  return response.getObject();
}

代码示例来源:origin: qaprosoft/zafira

zc = new ZafiraClient(ZAFIRA_URL);
ZAFIRA_ENABLED =  zc.isAvailable();
  Response<AuthTokenType> auth = zc.refreshToken(ZAFIRA_ACCESS_TOKEN);
  if(auth.getStatus() == 200)
    zc.setAuthToken(auth.getObject().getType() + " " + auth.getObject().getAccessToken());

代码示例来源:origin: com.qaprosoft/zafira-client

/**
 * Registers new test run triggered by human.
 * 
 * @param testSuiteId - test suited id
 * @param userId - user id
 * @param configXML - test config XML
 * @param jobId - job id
 * @param ciConfig - ci config
 * @param startedBy - user id who started the suite
 * @param workItem - test work item
 * @return created test run
 */
public TestRunType registerTestRunByHUMAN(Long testSuiteId, Long userId, String configXML, Long jobId, CIConfig ciConfig, Initiator startedBy, String workItem) 
{
  TestRunType testRun = new TestRunType(ciConfig.getCiRunId(), testSuiteId, userId, ciConfig.getGitUrl(), ciConfig.getGitBranch(), ciConfig.getGitCommit(), configXML, jobId, ciConfig.getCiBuild(), startedBy, workItem);
  String testRunDetails = "testSuiteId: %s, userId: %s, scmURL: %s, scmBranch: %s, scmCommit: %s, jobId: %s, buildNumber: %s, startedBy: %s, workItem";
  LOGGER.debug("Test Run details for registration:" + String.format(testRunDetails, testSuiteId, userId, ciConfig.getGitUrl(), ciConfig.getGitBranch(), ciConfig.getGitCommit(), jobId, ciConfig.getCiBuild(), startedBy, workItem));
  
  Response<TestRunType> response = startTestRun(testRun);
  testRun = response.getObject();
  if (testRun == null) 
  {
    throw new RuntimeException("Unable to register test run '" + String.format(testRunDetails, testSuiteId, userId,
        ciConfig.getGitUrl(), ciConfig.getGitBranch(), ciConfig.getGitCommit(), jobId, ciConfig.getCiBuild(), startedBy, workItem) + "' for zafira service: " + serviceURL);
  } else {
    LOGGER.debug("Registered test run details:" 
            + String.format(testRunDetails, testSuiteId, userId, ciConfig.getGitUrl(), ciConfig.getGitBranch(), ciConfig.getGitCommit(), jobId, ciConfig.getCiBuild(), startedBy, workItem));
  }
  return testRun;
}

代码示例来源:origin: com.qaprosoft/zafira-client

@Override
public void onTestFailedButWithinSuccessPercentage(ITestResult result)
{
  if(!ZAFIRA_ENABLED) return;
  
  try 
  {
    Response<TestType> rs = zc.finishTest(populateTestResult(result, Status.FAILED, getFullStackTrace(result)));
    if(rs.getStatus() != 200 && rs.getObject() == null)
    {
      throw new RuntimeException("Unable to register test " + rs.getObject().getName() + " for zafira service: " + ZAFIRA_URL);
    }
  } 
  catch (Throwable e) {
    LOGGER.error("Undefined error during test case/method finish!", e);
  }
}

代码示例来源:origin: com.qaprosoft/zafira-client

/**
 * Registers test re-run in Zafira.
 * 
 * @param test - test object
 * @return registered test
 */
public TestType registerTestRestart(TestType test) 
{
  String testName = test.getName();
  Response<TestType> response = startTest(test);
  test = response.getObject();
  if (test == null) 
  {
    throw new RuntimeException("Unable to register test '" + testName + "' restart for zafira service: " + serviceURL);
  } 
  else 
  {
    LOGGER.debug("Registered test restart details:'" + testName + "'; startTime: " + new Date(test.getStartTime()));
  }
  return test;
}

相关文章