-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor http client * Implement UriBuilder * Add lifecycle class * Generify HttpClient * Increase version * Fix bug with cnfig values overriding * Fix javadoc
- Loading branch information
Showing
21 changed files
with
399 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 0 additions & 80 deletions
80
...tegrations-core/src/main/java/aquality/tracking/integrations/core/AqualityHttpClient.java
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
...ons-core/src/main/java/aquality/tracking/integrations/core/AqualityTrackingLifecycle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package aquality.tracking.integrations.core; | ||
|
||
import aquality.tracking.integrations.core.configuration.IConfiguration; | ||
import aquality.tracking.integrations.core.endpoints.ISuiteEndpoints; | ||
import aquality.tracking.integrations.core.endpoints.ITestEndpoints; | ||
import aquality.tracking.integrations.core.endpoints.ITestResultEndpoints; | ||
import aquality.tracking.integrations.core.endpoints.ITestRunEndpoints; | ||
import aquality.tracking.integrations.core.models.Suite; | ||
import aquality.tracking.integrations.core.models.Test; | ||
import aquality.tracking.integrations.core.models.TestResult; | ||
import aquality.tracking.integrations.core.models.TestRun; | ||
import aquality.tracking.integrations.core.utilities.FileUtils; | ||
import com.google.inject.Guice; | ||
import com.google.inject.Injector; | ||
|
||
import java.io.File; | ||
import java.nio.file.Paths; | ||
import java.util.Collections; | ||
|
||
public class AqualityTrackingLifecycle { | ||
|
||
private static final Injector INJECTOR = Guice.createInjector(new ServicesModule()); | ||
|
||
private static TestRun currentTestRun; | ||
private static Suite currentSuite; | ||
|
||
private final ThreadLocal<Test> currentTest = new ThreadLocal<>(); | ||
private final ThreadLocal<TestResult> currentTestResult = new ThreadLocal<>(); | ||
|
||
private final IConfiguration configuration; | ||
private final ISuiteEndpoints suiteEndpoints; | ||
private final ITestRunEndpoints testRunEndpoints; | ||
private final ITestEndpoints testEndpoints; | ||
private final ITestResultEndpoints testResultEndpoints; | ||
|
||
public AqualityTrackingLifecycle() { | ||
configuration = INJECTOR.getInstance(IConfiguration.class); | ||
suiteEndpoints = INJECTOR.getInstance(ISuiteEndpoints.class); | ||
testRunEndpoints = INJECTOR.getInstance(ITestRunEndpoints.class); | ||
testEndpoints = INJECTOR.getInstance(ITestEndpoints.class); | ||
testResultEndpoints = INJECTOR.getInstance(ITestResultEndpoints.class); | ||
} | ||
|
||
public boolean isEnabled() { | ||
return configuration.isEnabled(); | ||
} | ||
|
||
public void startTestRun() { | ||
Suite suite = suiteEndpoints.createSuite(configuration.getSuiteName()); | ||
TestRun testRun = testRunEndpoints.startTestRun(suite.getId(), configuration.getBuildName(), | ||
configuration.getEnvironment(), configuration.getExecutor(), | ||
configuration.getCiBuild(), configuration.isDebug()); | ||
setCurrentSuite(suite); | ||
setCurrentTestRun(testRun); | ||
} | ||
|
||
private static void setCurrentSuite(final Suite suite) { | ||
currentSuite = suite; | ||
} | ||
|
||
private static void setCurrentTestRun(final TestRun testRun) { | ||
currentTestRun = testRun; | ||
} | ||
|
||
public void startTestExecution(final String testName) { | ||
Test test = testEndpoints.createOrUpdateTest(testName, Collections.singletonList(currentSuite)); | ||
currentTest.set(test); | ||
TestResult testResult = testResultEndpoints.startTestResult(currentTestRun.getId(), currentTest.get().getId()); | ||
currentTestResult.set(testResult); | ||
} | ||
|
||
public void addAttachment(final String fileName, final byte[] attachmentData) { | ||
String filePath = Paths.get(configuration.getAttachmentsDirectory(), fileName).toString(); | ||
File attachmentFile = FileUtils.writeToFile(filePath, attachmentData); | ||
testResultEndpoints.addAttachment(currentTestResult.get().getId(), attachmentFile); | ||
} | ||
|
||
public void finishTestExecution(final int finalResultId, final String failReason) { | ||
testResultEndpoints.finishTestResult(currentTestResult.get().getId(), finalResultId, failReason); | ||
currentTest.remove(); | ||
currentTestResult.remove(); | ||
} | ||
|
||
public void finishTestRun() { | ||
testRunEndpoints.finishTestRun(currentTestRun.getId()); | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
...king-integrations-core/src/main/java/aquality/tracking/integrations/core/IHttpClient.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.