diff --git a/README.rst b/README.rst index bf2ee0f..84a6c65 100644 --- a/README.rst +++ b/README.rst @@ -56,34 +56,37 @@ or .. code:: java public class Example { - public static void main(String[] a) { - TestRailClient client = TestRailClientBuilder - .build("user", "pass", "http://localhost"); - - Project project = client.addProject("name", "announcement", true, 3); - - Section section = new Section() - .withName(UUID.randomUUID().toString()) - .withDescription(UUID.randomUUID().toString()); - - Section section = client.addSection(section, project.getId()); - - Case caze = new Case() - .withTitle("test_20190101201312") - .withPriorityId(CRITICAL.getId()) - .withSuiteId(section.getSuiteId()) - .withRefs("JIRA-123") - .withTypeId(ACCEPTANCE.getId()) - .withTemplateId(TEST_CASE_TEXT.getId()) - .withEstimate("1m 45s") - .withCustomPreconds("withCustomPreconds") - .withCustomSteps("withCustomSteps") - .withCustomExpected("withCustomExpected") - .withCustomStepsSeparated(null); - - Case caze = client.addCase(caze, section); - System.out.println(caze.getId()); - } + public static void main(String[] a) { + TestRailClient client = TestRailClientBuilder + .build("user", "pass", "http://localhost"); + + TRProject trProject = new TRProject() + .withName("name") + .withAnnouncement("Announcement") + .withSuiteMode(MULTIPLE.getId()); + TRProject resultProject = client.addProject(trProject); + + TRSection trSection = new TRSection() + .withName(UUID.randomUUID().toString()) + .withDescription(UUID.randomUUID().toString()); + TRSection resultSection = client.addSection(trSection, resultProject); + + TRCase trCase = new TRCase() + .withTitle("test_20190101201312") + .withPriorityId(CRITICAL.getId()) + .withSuiteId(resultSection.getSuiteId()) + .withRefs("JIRA-123") + .withTypeId(ACCEPTANCE.getId()) + .withTemplateId(TEST_CASE_TEXT.getId()) + .withEstimate(new Estimate().withHour(4).toString()) + .withCustomPreconds("withCustomPreconds") + .withCustomSteps("withCustomSteps") + .withCustomExpected("withCustomExpected") + .withCustomStepsSeparated(null); + TRCase resultCase = client.addCase(trCase, resultSection); + + System.out.println(resultCase.getId()); + } } * You can build the Feign client yourself and customize it to fit your needs. diff --git a/docs/index.rst b/docs/index.rst index d0470f7..012f990 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -37,34 +37,42 @@ Build client using `TestRailClientBuilder` and call the necessary method .. code:: java import org.touchbit.testrail4j.jackson2.gson.feign.TestRailClientBuilder; - import org.touchbit.testrail4j.core.BasicAuth; - import org.touchbit.testrail4j.jackson2.model.Case; + import org.touchbit.testrail4j.jackson2.model.*; + import org.touchbit.testrail4j.core.field.*; + import org.touchbit.testrail4j.core.type.*; public class Example { - public static void main(String[] a) { - TestRailClient client = TestRailClientBuilder - .build("user", "pass", "http://localhost"); - - Project project = client.addProject("name", "announcement", true, 3); - Section section = new Section() - .withName(UUID.randomUUID().toString()) - .withDescription(UUID.randomUUID().toString()); - Section section = client.addSection(section, project.getId()); - Case caze = new Case() - .withTitle("test_20190101201312") - .withPriorityId(CRITICAL.getId()) - .withSuiteId(section.getSuiteId()) - .withRefs("JIRA-123") - .withTypeId(ACCEPTANCE.getId()) - .withTemplateId(TEST_CASE_TEXT.getId()) - .withEstimate("1m 45s") - .withCustomPreconds("withCustomPreconds") - .withCustomSteps("withCustomSteps") - .withCustomExpected("withCustomExpected") - .withCustomStepsSeparated(null); - Case caze = client.addCase(caze, section); - System.out.println(caze.getId()); - } + public static void main(String[] a) { + TestRailClient client = TestRailClientBuilder + .build("user", "pass", "http://localhost"); + + TRProject trProject = new TRProject() + .withName("name") + .withAnnouncement("Announcement") + .withSuiteMode(MULTIPLE.getId()); + TRProject resultProject = client.addProject(trProject); + + TRSection trSection = new TRSection() + .withName(UUID.randomUUID().toString()) + .withDescription(UUID.randomUUID().toString()); + TRSection resultSection = client.addSection(trSection, resultProject); + + TRCase trCase = new TRCase() + .withTitle("test_20190101201312") + .withPriorityId(CRITICAL.getId()) + .withSuiteId(resultSection.getSuiteId()) + .withRefs("JIRA-123") + .withTypeId(ACCEPTANCE.getId()) + .withTemplateId(TEST_CASE_TEXT.getId()) + .withEstimate(new Estimate().withHour(4).toString()) + .withCustomPreconds("withCustomPreconds") + .withCustomSteps("withCustomSteps") + .withCustomExpected("withCustomExpected") + .withCustomStepsSeparated(null); + TRCase resultCase = client.addCase(trCase, resultSection); + + System.out.println(resultCase.getId()); + } } Restrictions diff --git a/testrail4j-core/src/main/java/org/touchbit/testrail4j/core/field/Estimate.java b/testrail4j-core/src/main/java/org/touchbit/testrail4j/core/field/Estimate.java new file mode 100644 index 0000000..d00a215 --- /dev/null +++ b/testrail4j-core/src/main/java/org/touchbit/testrail4j/core/field/Estimate.java @@ -0,0 +1,89 @@ +package org.touchbit.testrail4j.core.field; + +import java.util.StringJoiner; + +/** + * The estimate, e.g. ā30sā or ā1m 45sā + * + *
+ * Created by Oleg Shaburov on 18.09.2020
+ * shaburov.o.a@gmail.com
+ */
+public class Estimate {
+
+ private int day = 0;
+ private int hour = 0;
+ private int min = 0;
+ private int sec = 0;
+
+ public int getDay() {
+ return day;
+ }
+
+ public int getMin() {
+ return min;
+ }
+
+ public int getSec() {
+ return sec;
+ }
+
+ public void setDay(int day) {
+ this.day = day;
+ }
+
+ public void setMin(int min) {
+ this.min = min;
+ }
+
+ public void setSec(int sec) {
+ this.sec = sec;
+ }
+
+ public int getHour() {
+ return hour;
+ }
+
+ public void setHour(int hour) {
+ this.hour = hour;
+ }
+
+ public Estimate withDay(int day) {
+ this.day = day;
+ return this;
+ }
+
+ public Estimate withHour(int hour) {
+ this.hour = hour;
+ return this;
+ }
+
+ public Estimate withMin(int min) {
+ this.min = min;
+ return this;
+ }
+
+ public Estimate withSec(int sec) {
+ this.sec = sec;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ StringJoiner stringJoiner = new StringJoiner(" ");
+ if (day > 0) {
+ stringJoiner.add(day + "d");
+ }
+ if (hour > 0) {
+ stringJoiner.add(hour + "h");
+ }
+ if (min > 0) {
+ stringJoiner.add(min + "m");
+ }
+ if (sec > 0) {
+ stringJoiner.add(sec + "s");
+ }
+ return stringJoiner.toString();
+ }
+
+}
diff --git a/testrail4j-core/src/test/java/org/touchbit/testrail4j/core/FieldTests.java b/testrail4j-core/src/test/java/org/touchbit/testrail4j/core/FieldTests.java
new file mode 100644
index 0000000..a9e8b62
--- /dev/null
+++ b/testrail4j-core/src/test/java/org/touchbit/testrail4j/core/FieldTests.java
@@ -0,0 +1,23 @@
+package org.touchbit.testrail4j.core;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.touchbit.testrail4j.core.field.Estimate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("DTO fields classes tests")
+public class FieldTests {
+
+ @Test
+ @DisplayName("Estimate.class")
+ void unitTest_20200918164754() {
+ Estimate estimate = new Estimate()
+ .withDay(1)
+ .withHour(2)
+ .withMin(3)
+ .withSec(4);
+ assertThat(estimate).hasToString("1d 2h 3m 4s");
+ }
+
+}
diff --git a/testrail4j-integration-tests/src/main/java/org/touchbit/testrail4j/integration/tests/gson/CaseFieldTests.java b/testrail4j-integration-tests/src/main/java/org/touchbit/testrail4j/integration/tests/gson/CaseFieldTests.java
index 4ceb739..a97329c 100644
--- a/testrail4j-integration-tests/src/main/java/org/touchbit/testrail4j/integration/tests/gson/CaseFieldTests.java
+++ b/testrail4j-integration-tests/src/main/java/org/touchbit/testrail4j/integration/tests/gson/CaseFieldTests.java
@@ -59,10 +59,10 @@ public void test_20200106014139() {
public void test_20200106015332() {
TRProject project = CLIENT.getProject();
TRCaseFieldConfig config = new TRCaseFieldConfig()
- .withContext(new Context()
+ .withContext(new TRCaseFieldConfigContext()
.withIsGlobal(false)
.withProjectIds(new ArrayList