Skip to content

Commit 9b06624

Browse files
Merge pull request #9 from chapeco/dev
Dev merge into Master
2 parents 3981103 + cf05f15 commit 9b06624

33 files changed

+316
-161
lines changed

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<version>1.0-SNAPSHOT</version>
1010

1111
<properties>
12-
<kotlin.version>1.2.70</kotlin.version>
12+
<kotlin.version>1.2.71</kotlin.version>
1313
<serialization.version>0.6.2</serialization.version>
1414
</properties>
1515

@@ -70,6 +70,17 @@
7070
<artifactId>junit-jupiter-api</artifactId>
7171
<version>5.3.1</version>
7272
</dependency>
73+
<dependency>
74+
<groupId>io.mockk</groupId>
75+
<artifactId>mockk</artifactId>
76+
<version>1.8.10</version>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.jetbrains.kotlin</groupId>
81+
<artifactId>kotlin-stdlib-jdk8</artifactId>
82+
<version>${kotlin.version}</version>
83+
</dependency>
7384
</dependencies>
7485

7586
<build>

src/main/kotlin/io/github/chapeco/DataTypes/Case.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package io.github.chapeco.DataTypes
22

33
import io.github.chapeco.Utilities.Timespan
44
import io.github.chapeco.Utilities.Timestamp
5+
import io.github.chapeco.Utilities.Request
56
import kotlinx.serialization.*
7+
import kotlinx.serialization.json.JSON
68

79
@Serializable
810
data class Case
@@ -22,7 +24,14 @@ data class Case
2224
@Optional @SerialName("priority_id") var priorityId: Int? = null,
2325
@Transient var estimate: Timespan? = null,
2426
@Optional @SerialName("milestone_id") var milestoneId: Int? = null,
25-
@Optional var refs: String? = null
27+
@Optional var refs: String? = null,
28+
@Optional @SerialName("custom_automation_type") var automationType: String? = null,
29+
@Optional @SerialName("custom_expected") var expected: String? = null,
30+
@Optional @SerialName("custom_preconds") var preconds: String? = null,
31+
@Optional @SerialName("custom_steps") var steps: String? = null,
32+
@Optional @SerialName("custom_steps_separated") var stepsSeparated: String? = null,
33+
@Optional @SerialName("custom_mission") var mission: String? = null,
34+
@Optional @SerialName("custom_goals") var goals: String? = null
2635
)
2736
{
2837
@Optional @SerialName("created_on") private val createdOnActual: Long? = createdOn.toString().toLongOrNull()
@@ -41,7 +50,7 @@ data class Case
4150
fun getCase(caseId: Int): Case
4251
{
4352
val endpoint = "get_case/$caseId"
44-
return Case()
53+
return JSON.unquoted.parse<Case>(Request().Get(endpoint)!!)
4554
}
4655

4756
fun getCases
@@ -59,7 +68,7 @@ data class Case
5968
updatedAfter: Timestamp? = null,
6069
updatedBefore: Timestamp? = null,
6170
updatedBy: Array<Int>? = null
62-
): Array<Case>
71+
): List<Case>
6372
{
6473
val endpoint = StringBuilder()
6574
endpoint.append("get_cases/$projectId")
@@ -76,16 +85,16 @@ data class Case
7685
if(updatedBefore != null) endpoint.append("&updated_before=$updatedBefore")
7786
if(updatedBy != null) endpoint.append("&updated_by=$updatedBy")
7887

79-
return Array<Case>(0) {Case()}
88+
return JSON.unquoted.parse(Case.serializer().list, Request().Get(endpoint.toString())!!)
8089
}
8190

82-
fun addCase(sectionId: Int): Case
91+
fun addCase(sectionId: Int, case: Case): Case
8392
{
8493
val endpoint = "add_case/$sectionId"
8594
return Case()
8695
}
8796

88-
fun updateCase(caseId: Int): Case
97+
fun updateCase(caseId: Int, case: Case): Case
8998
{
9099
val endpoint = "update_case/$caseId"
91100
return Case()

src/main/kotlin/io/github/chapeco/DataTypes/CaseField.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import io.github.chapeco.Utilities.Type
45
import kotlinx.serialization.SerialName
56
import kotlinx.serialization.Serializable
7+
import kotlinx.serialization.json.JSON
8+
import kotlinx.serialization.list
69

710
@Serializable
811
data class CaseField
@@ -30,10 +33,10 @@ data class CaseField
3033
)
3134
{
3235
//TODO
33-
fun getCaseFields(): Array<CaseField>
36+
fun getCaseFields(): List<CaseField>
3437
{
3538
val endpoint = "get_case_fields/"
36-
return Array<CaseField>(0) {CaseField()}
39+
return JSON.unquoted.parse(CaseField.serializer().list, Request().Get(endpoint)!!)
3740
}
3841

3942
fun addCaseField(): CaseField

src/main/kotlin/io/github/chapeco/DataTypes/CaseType.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import kotlinx.serialization.SerialName
45
import kotlinx.serialization.Serializable
6+
import kotlinx.serialization.json.JSON
7+
import kotlinx.serialization.list
58

69
@Serializable
710
data class CaseType
@@ -13,9 +16,9 @@ data class CaseType
1316
)
1417
{
1518
//TODO
16-
fun getCaseTypes(): Array<CaseType>
19+
fun getCaseTypes(): List<CaseType>
1720
{
1821
val endpoint = "get_case_types"
19-
return Array<CaseType>(0) {CaseType()}
22+
return JSON.unquoted.parse(CaseType.serializer().list, Request().Get(endpoint)!!)
2023
}
2124
}

src/main/kotlin/io/github/chapeco/DataTypes/Configuration.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import kotlinx.serialization.SerialName
45
import kotlinx.serialization.Serializable
6+
import kotlinx.serialization.json.JSON
7+
import kotlinx.serialization.list
58

69
@Serializable
710
data class Configuration
@@ -15,10 +18,10 @@ data class Configuration
1518
)
1619
{
1720
//TODO
18-
fun getConfigs(projectId: Int): Array<Configuration>
21+
fun getConfigs(projectId: Int): List<Configuration>
1922
{
2023
val endpoint = "get_configs/$projectId"
21-
return Array<Configuration>(0) {Configuration()}
24+
return JSON.unquoted.parse(Configuration.serializer().list, Request().Get(endpoint)!!)
2225
}
2326

2427
fun addConfigGroup(projectId: Int)

src/main/kotlin/io/github/chapeco/DataTypes/Milestone.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import io.github.chapeco.Utilities.Timestamp
4-
import kotlinx.serialization.Optional
5-
import kotlinx.serialization.SerialName
6-
import kotlinx.serialization.Serializable
7-
import kotlinx.serialization.Transient
5+
import kotlinx.serialization.*
6+
import kotlinx.serialization.json.JSON
87

98
@Serializable
109
data class Milestone
@@ -45,16 +44,16 @@ data class Milestone
4544
fun getMilestone(milestoneId: Int): Milestone
4645
{
4746
val endpoint = "get_milestone/$milestoneId"
48-
return Milestone()
47+
return JSON.unquoted.parse(Request().Get(endpoint)!!)
4948
}
5049

51-
fun getMilestones(projectId: Int, isCompleted: Boolean? = null, isStarted: Boolean? = null): Array<Milestone>
50+
fun getMilestones(projectId: Int, isCompleted: Boolean? = null, isStarted: Boolean? = null): List<Milestone>
5251
{
5352
val endpoint = StringBuilder()
5453
endpoint.append("get_milestones/$projectId")
5554
if(isCompleted != null) endpoint.append("&is_completed=$isCompleted")
5655
if(isStarted != null) endpoint.append("&is_started=$isStarted")
57-
return Array<Milestone>(0) {Milestone()}
56+
return JSON.unquoted.parse(Milestone.serializer().list, Request().Get(endpoint.toString())!!)
5857
}
5958

6059
fun addMilestone(projectId: Int): Milestone

src/main/kotlin/io/github/chapeco/DataTypes/Plan.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import io.github.chapeco.Utilities.Timestamp
4-
import kotlinx.serialization.Optional
5-
import kotlinx.serialization.SerialName
6-
import kotlinx.serialization.Serializable
7-
import kotlinx.serialization.Transient
5+
import kotlinx.serialization.*
6+
import kotlinx.serialization.json.JSON
87

98
@Serializable
109
data class Plan
@@ -45,7 +44,7 @@ data class Plan
4544
fun getPlan(planId: Int): Plan
4645
{
4746
val endpoint = "get_plan/$planId"
48-
return Plan()
47+
return JSON.unquoted.parse(Request().Get(endpoint)!!)
4948
}
5049

5150
fun getPlans
@@ -58,7 +57,7 @@ data class Plan
5857
limit: Int? = null,
5958
offset: Int? = null,
6059
milestoneId: Array<Int>? = null
61-
): Array<Plan>
60+
): List<Plan>
6261
{
6362
val endpoint = StringBuilder()
6463
endpoint.append("get_plans/$projectId")
@@ -69,7 +68,7 @@ data class Plan
6968
if(limit != null) endpoint.append("&limit=$limit")
7069
if(offset != null) endpoint.append("&offset=$offset")
7170
if(milestoneId != null) endpoint.append("&milestone_id=$milestoneId")
72-
return Array<Plan>(0) {Plan()}
71+
return JSON.unquoted.parse(Plan.serializer().list, Request().Get(endpoint.toString())!!)
7372
}
7473

7574
fun addPlan(projectId: Int): Plan

src/main/kotlin/io/github/chapeco/DataTypes/Priority.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import kotlinx.serialization.SerialName
45
import kotlinx.serialization.Serializable
6+
import kotlinx.serialization.json.JSON
7+
import kotlinx.serialization.list
58

69
@Serializable
710
data class Priority
@@ -15,9 +18,9 @@ data class Priority
1518
)
1619
{
1720
//TODO
18-
fun getPriorities(): Array<Priority>
21+
fun getPriorities(): List<Priority>
1922
{
2023
val endpoint = "get_priorities"
21-
return Array<Priority>(0) {Priority()}
24+
return JSON.unquoted.parse(Priority.serializer().list, Request().Get(endpoint)!!)
2225
}
2326
}

src/main/kotlin/io/github/chapeco/DataTypes/Project.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import io.github.chapeco.Utilities.Timestamp
4-
import kotlinx.serialization.Optional
5-
import kotlinx.serialization.SerialName
6-
import kotlinx.serialization.Serializable
7-
import kotlinx.serialization.Transient
5+
import kotlinx.serialization.*
6+
import kotlinx.serialization.json.JSON
87

98
@Serializable
109
data class Project
@@ -34,16 +33,16 @@ data class Project
3433
fun getProject(projectId: Int): Project
3534
{
3635
val endpoint = "get_project/$projectId"
37-
return Project()
36+
return JSON.unquoted.parse(Request().Get(endpoint)!!)
3837
}
3938

40-
fun getProjects(isCompleted: Boolean? = null): Array<Project>
39+
fun getProjects(isCompleted: Boolean? = null): List<Project>
4140
{
4241
val endpoint = StringBuilder()
4342
endpoint.append("get_projects")
4443
if(isCompleted != null) endpoint.append("&is_completed=$isCompleted")
4544

46-
return Array<Project>(0) {Project()}
45+
return JSON.unquoted.parse(Project.serializer().list,Request().Get(endpoint.toString())!!)
4746
}
4847

4948
fun addProject(): Project

src/main/kotlin/io/github/chapeco/DataTypes/Result.kt

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package io.github.chapeco.DataTypes
22

3+
import io.github.chapeco.Utilities.Request
34
import io.github.chapeco.Utilities.Timespan
45
import io.github.chapeco.Utilities.Timestamp
5-
import kotlinx.serialization.Optional
6-
import kotlinx.serialization.SerialName
7-
import kotlinx.serialization.Serializable
8-
import kotlinx.serialization.Transient
6+
import kotlinx.serialization.*
7+
import kotlinx.serialization.json.JSON
98

109
@Serializable
1110
data class Result
@@ -25,12 +24,12 @@ data class Result
2524
@SerialName("assignedto_id") var assignedToId: Int? = null
2625
)
2726
{
28-
@Optional @SerialName("created_on") private val createdOnActual: Long? = createdOn.toString().toLong()
29-
@Optional @SerialName("elapsed") private val elapsedActual: String? = elapsed.toString()
27+
@Optional @SerialName("created_on") private val createdOnActual: Long? = if(createdOn != null) createdOn.toString().toLong() else -1
28+
@Optional @SerialName("elapsed") private val elapsedActual: String? = if(elapsed != null) elapsed.toString() else "-1"
3029

3130
init {
3231
if(createdOn == null) createdOn = Timestamp(createdOnActual)
33-
if(elapsed == null) elapsed = Timespan().parseTimespan(elapsedActual)
32+
if(elapsed == null) elapsed = Timespan().parseTimespan(elapsedActual!!)
3433
}
3534

3635
//TODO
@@ -40,15 +39,15 @@ data class Result
4039
limit: Int? = null,
4140
offset: Int? = null,
4241
statusId: Array<Int>? = null
43-
): Array<Result>
42+
): List<Result>
4443
{
4544
val endpoint = StringBuilder()
4645
endpoint.append("get_results/$testId")
4746
if(limit != null) endpoint.append("&limit=$limit")
4847
if(offset != null) endpoint.append("&offset=$offset")
4948
if(statusId != null) endpoint.append("&status_id=$statusId")
5049

51-
return Array<Result>(0) {Result()}
50+
return JSON.unquoted.parse(Result.serializer().list, Request().Get(endpoint.toString())!!)
5251
}
5352

5453
fun getResultsForCase
@@ -58,15 +57,15 @@ data class Result
5857
limit: Int? = null,
5958
offset: Int? = null,
6059
statusId: Int? = null
61-
): Array<Result>
60+
): List<Result>
6261
{
6362
val endpoint = StringBuilder()
6463
endpoint.append("get_results_for_case/$runId/$caseId")
6564
if(limit != null) endpoint.append("&limit=$limit")
6665
if(offset != null) endpoint.append("&offset=$offset")
6766
if(statusId != null) endpoint.append("&status_id=$statusId")
6867

69-
return Array<Result>(0) {Result()}
68+
return JSON.unquoted.parse(Result.serializer().list, Request().Get(endpoint.toString())!!)
7069
}
7170

7271
fun getResultsForRun
@@ -78,7 +77,7 @@ data class Result
7877
limit: Int? = null,
7978
offset: Int? = null,
8079
statusId: Array<Int>? = null
81-
): Array<Result>
80+
): List<Result>
8281
{
8382
val endpoint = StringBuilder()
8483
endpoint.append("get_results_for_run/$runId")
@@ -89,13 +88,13 @@ data class Result
8988
if(offset != null) endpoint.append("&offset=$offset")
9089
if(statusId != null) endpoint.append("&status_id=$statusId")
9190

92-
return Array<Result>(0) {Result()}
91+
return JSON.unquoted.parse(Result.serializer().list, Request().Get(endpoint.toString())!!)
9392
}
9493

95-
fun addResult(testId: Int): Result
94+
fun addResult(result: Result): Result
9695
{
9796
val endpoint = "add_result/$testId"
98-
return Result()
97+
return JSON.unquoted.parse(Request().Post(endpoint,JSON.stringify(Result))!!)
9998
}
10099

101100
fun addResultForCase(runId: Int, caseId: Int): Result

0 commit comments

Comments
 (0)