Skip to content

Commit

Permalink
Fixed filter for get autotest method (#102)
Browse files Browse the repository at this point in the history
* Fixed filter for get autotest method

* Fixed tests

---------

Co-authored-by: Dmitry.Gridnev <[email protected]>
  • Loading branch information
gibiw and Dmitry.Gridnev authored Sep 26, 2023
1 parent 58d8c74 commit cf561ab
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=1.4.0
version=1.4.1

org.gradle.daemon=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public TmsApiClient(ClientConfiguration config) {

@Override
public TestRunV2GetModel createTestRun() throws ApiException {


CreateEmptyRequest model = new CreateEmptyRequest();
model.setProjectId(UUID.fromString(clientConfiguration.getProjectId()));

Expand Down Expand Up @@ -94,6 +92,7 @@ public AutoTestModel getAutoTestByExternalId(String externalId) throws ApiExcept
Set<UUID> projectIds = new HashSet<>();
projectIds.add(UUID.fromString(this.clientConfiguration.getProjectId()));
filter.setProjectIds(projectIds);
filter.setIsDeleted(false);

Set<String> externalIds = new HashSet<>();
externalIds.add(externalId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ public void writeTest(TestResult testResult) {
}
apiClient.linkAutoTestToWorkItem(autoTestId, i);
} catch (ApiException e) {
LOGGER.error("Can not link the autotest: ".concat(e.getMessage()));
LOGGER.error("Can not link the autotest: " + e.getMessage());
}
});
} catch (ApiException e) {
LOGGER.error("Can not write the autotest: ".concat(e.getMessage()));
LOGGER.error("Can not write the autotest: " + (e.getMessage()));
}
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public void writeClass(ClassContainer container) {

apiClient.updateAutoTest(autoTestPutModel);
} catch (ApiException e) {
LOGGER.error("Can not write the class: ".concat(e.getMessage()));
LOGGER.error("Can not write the class: " + (e.getMessage()));
}
});
}
Expand Down Expand Up @@ -196,7 +196,7 @@ public void writeTests(MainContainer container) {
apiClient.updateTestResult(testResultId, model);

} catch (ApiException e) {
LOGGER.error("Can not update the autotest: ".concat(e.getMessage()));
LOGGER.error("Can not update the autotest: " + (e.getMessage()));
}
});
}
Expand All @@ -209,7 +209,7 @@ public String writeAttachment(String path) {
try {
return apiClient.addAttachment(path);
} catch (ApiException e) {
LOGGER.error("Can not write attachment: ".concat(e.getMessage()));
LOGGER.error("Can not write attachment: " + (e.getMessage()));

return "";
}
Expand Down
9 changes: 5 additions & 4 deletions testit-java-commons/src/test/java/ru/testit/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public static AutoTestModel generateAutoTestModel(String projectId) {
return model;
}

public static AutoTestPutModel generateAutoTestPutModel(String projectId) {
AutoTestPutModel model = new AutoTestPutModel();
public static UpdateAutoTestRequest generateAutoTestPutModel(String projectId) {
UpdateAutoTestRequest model = new UpdateAutoTestRequest();

model.setTitle(TITLE);
model.setExternalId(EXTERNAL_ID);
Expand All @@ -136,12 +136,13 @@ public static AutoTestPutModel generateAutoTestPutModel(String projectId) {
model.setSetup(new ArrayList<>());
model.setTeardown(new ArrayList<>());
model.setId(UUID.fromString(TEST_UUID));
model.isFlaky(null);

return model;
}

public static AutoTestPostModel generateAutoTestPostModel(String projectId) {
AutoTestPostModel model = new AutoTestPostModel();
public static CreateAutoTestRequest generateAutoTestPostModel(String projectId) {
CreateAutoTestRequest model = new CreateAutoTestRequest();

model.setTitle(TITLE);
model.setExternalId(EXTERNAL_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import org.junit.jupiter.api.Test;
import ru.testit.Helper;
import ru.testit.client.invoker.ApiException;
import ru.testit.client.model.AutoTestModel;
import ru.testit.client.model.AutoTestPostModel;
import ru.testit.client.model.AutoTestPutModel;
import ru.testit.client.model.LinkPutModel;
import ru.testit.client.model.*;
import ru.testit.clients.ApiClient;
import ru.testit.clients.ClientConfiguration;
import ru.testit.models.*;
import ru.testit.models.LinkType;
import ru.testit.services.ResultStorage;

import java.util.ArrayList;
Expand Down Expand Up @@ -46,7 +44,7 @@ void writeTest_WithExistingAutoTest_InvokeUpdateHandler() throws ApiException {
// arrange
TestResult testResult = Helper.generateTestResult();
AutoTestModel response = Helper.generateAutoTestModel(config.getProjectId());
AutoTestPutModel request = Helper.generateAutoTestPutModel(config.getProjectId());
UpdateAutoTestRequest request = Helper.generateAutoTestPutModel(config.getProjectId());
List<UUID> uuids = Helper.generateListUuid();
request.setId(null);

Expand All @@ -66,7 +64,7 @@ void writeTest_WithExistingAutoTest_InvokeUpdateHandler() throws ApiException {
void writeTest_WithCreatingAutoTest_InvokeCreateHandler() throws ApiException {
// arrange
TestResult testResult = Helper.generateTestResult();
AutoTestPostModel request = Helper.generateAutoTestPostModel(config.getProjectId());
CreateAutoTestRequest request = Helper.generateAutoTestPostModel(config.getProjectId());
List<UUID> uuids = Helper.generateListUuid();

when(client.getAutoTestByExternalId(testResult.getExternalId())).thenReturn(null);
Expand Down Expand Up @@ -158,7 +156,7 @@ void writeTest_FiledExistingAutoTest_InvokeUpdateHandler() throws ApiException {
putLink.setType(ru.testit.client.model.LinkType.DEFECT);
putLinks.add(putLink);

AutoTestPutModel putModel = Helper.generateAutoTestPutModel(config.getProjectId());
UpdateAutoTestRequest putModel = Helper.generateAutoTestPutModel(config.getProjectId());
putModel.links(putLinks);

when(client.getAutoTestByExternalId(testResult.getExternalId())).thenReturn(response);
Expand All @@ -178,7 +176,7 @@ void writeTest_Failed_InvokeSendTestResult() throws ApiException {
// arrange
TestResult testResult = Helper.generateTestResult();
AutoTestModel response = Helper.generateAutoTestModel(config.getProjectId());
AutoTestPutModel request = Helper.generateAutoTestPutModel(config.getProjectId());
UpdateAutoTestRequest request = Helper.generateAutoTestPutModel(config.getProjectId());
request.setId(null);

when(client.getAutoTestByExternalId(testResult.getExternalId())).thenReturn(response);
Expand Down Expand Up @@ -208,7 +206,7 @@ void writeClass_WithoutAutoTest_NoInvokeUpdateHandler() throws ApiException {
writer.writeClass(container);

// assert
verify(client, never()).updateAutoTest(any(AutoTestPutModel.class));
verify(client, never()).updateAutoTest(any(UpdateAutoTestRequest.class));
}

@Test
Expand All @@ -217,7 +215,7 @@ void writeClass_WithAutoTest_InvokeUpdateHandler() throws ApiException {
ClassContainer container = Helper.generateClassContainer();
TestResult testResult = Helper.generateTestResult();
AutoTestModel response = Helper.generateAutoTestModel(config.getProjectId());
AutoTestPutModel request = Helper.generateAutoTestPutModel(config.getProjectId());
UpdateAutoTestRequest request = Helper.generateAutoTestPutModel(config.getProjectId());
request.getSetup().add(Helper.generateBeforeEachSetup());
request.getTeardown().add(Helper.generateAfterEachSetup());

Expand Down Expand Up @@ -250,7 +248,7 @@ void writeTests_WithoutAutoTest_NoInvokeUpdateHandler() throws ApiException {
writer.writeTests(container);

// assert
verify(client, never()).updateAutoTest(any(AutoTestPutModel.class));
verify(client, never()).updateAutoTest(any(UpdateAutoTestRequest.class));
verify(client, never()).updateTestResult(any(), any());
}

Expand All @@ -266,7 +264,7 @@ void writeTests_WithAutoTest_InvokeUpdateHandler() throws ApiException {
response.getSetup().add(Helper.generateBeforeEachSetup());
response.getTeardown().add(Helper.generateAfterEachSetup());

AutoTestPutModel request = Helper.generateAutoTestPutModel(config.getProjectId());
UpdateAutoTestRequest request = Helper.generateAutoTestPutModel(config.getProjectId());
request.getSetup().add(Helper.generateBeforeAllSetup());
request.getSetup().add(Helper.generateBeforeEachSetup());
request.getTeardown().add(Helper.generateAfterEachSetup());
Expand Down

0 comments on commit cf561ab

Please sign in to comment.