This repository has been archived by the owner on Mar 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverted back to original Edited by mistake
- Loading branch information
crowded
committed
Dec 11, 2019
1 parent
611b8d8
commit 927b553
Showing
16 changed files
with
2,609 additions
and
26 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
26 changes: 0 additions & 26 deletions
26
offix/src/androidTest/java/org/aerogear/offix/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
offix/src/androidTest/java/org/aerogear/offix/MainInstrumentedTest.kt
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,100 @@ | ||
package org.aerogear.offix | ||
|
||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.runner.AndroidJUnit4 | ||
import android.util.Log | ||
import com.apollographql.apollo.ApolloCall | ||
import com.apollographql.apollo.api.Input | ||
import com.apollographql.apollo.api.Response | ||
import com.apollographql.apollo.exception.ApolloException | ||
import org.aerogear.offix.Offline.Companion.getDb | ||
import org.aerogear.offix.persistence.Mutation | ||
import org.aerogear.offix.type.TaskInput | ||
import org.json.JSONObject | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see [Testing documentation](http://d.android.com/tools/testing) | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
val input = TaskInput(Input.optional(0), "title", "desc", "test") | ||
val mutation = CreateTaskMutation(input) | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getTargetContext() | ||
assertEquals("org.aerogear.offixsdk.test", appContext.packageName) | ||
} | ||
|
||
@Test | ||
fun addMutationCheck(){ | ||
getDb()?.mutationDao()?.deleteAllMutations() | ||
var a = getDb()?.mutationDao()?.getAllMutations()?.size | ||
assertEquals(0, a) | ||
val m = Mutation(mutation.operationId(), mutation.queryDocument(), mutation.name(), JSONObject(mutation.variables().valueMap()), mutation.responseFieldMapper().javaClass.simpleName) | ||
getDb()!!.mutationDao().insertMutation(m) | ||
a = getDb()?.mutationDao()?.getAllMutations()?.size | ||
assertEquals(1, a) | ||
} | ||
|
||
@Test | ||
fun discreteObjectCheck(){ | ||
val m1 = Mutation(mutation.operationId(), mutation.queryDocument(), mutation.name(), JSONObject(mutation.variables().valueMap()), mutation.responseFieldMapper().javaClass.simpleName) | ||
val m2 = getDb()!!.mutationDao().getAMutation(0) | ||
assertTrue(!m1.equals(m2)) | ||
} | ||
|
||
@Test | ||
fun deleteMutationCheck(){ | ||
var a = getDb()?.mutationDao()?.getAllMutations()?.size | ||
assertEquals(1, a) | ||
getDb()?.mutationDao()?.deleteAllMutations() | ||
a = getDb()?.mutationDao()?.getAllMutations()?.size | ||
assertEquals(0, a) | ||
} | ||
|
||
@Test | ||
fun getAllTasksWorking(){ | ||
val callback = object : ApolloCall.Callback<FindAllTasksQuery.Data>() { | ||
|
||
override fun onFailure(e: ApolloException) { | ||
e.printStackTrace() | ||
Log.e("TAG", "getTasks ----$e ") | ||
assert(false) | ||
} | ||
|
||
override fun onResponse(response: Response<FindAllTasksQuery.Data>) { | ||
Log.e("TAG", "on Response getTasks : Data ${response.data()}") | ||
assert(true) | ||
} | ||
} | ||
Offline.apClient?.query(FindAllTasksQuery())?.watcher() | ||
?.enqueueAndWatch(callback) | ||
} | ||
|
||
@Test | ||
fun getAllUsersWorking(){ | ||
val callback = object : ApolloCall.Callback<FindAllUsersQuery.Data>() { | ||
|
||
override fun onFailure(e: ApolloException) { | ||
e.printStackTrace() | ||
Log.e("TAG", "getTasks ----$e ") | ||
assert(false) | ||
} | ||
|
||
override fun onResponse(response: Response<FindAllUsersQuery.Data>) { | ||
Log.e("TAG", "on Response getTasks : Data ${response.data()}") | ||
assert(true) | ||
} | ||
} | ||
Offline.apClient?.query(FindAllUsersQuery())?.watcher() | ||
?.enqueueAndWatch(callback) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
offix/src/main/graphql/org.aerogear.offix/checkAndUpdateTask.graphql
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,26 @@ | ||
mutation checkAndUpdateTask($id: ID!, $title: String, $description: String, $version: Int!, $status: String!){ | ||
checkAndUpdateTask(id: $id, title: $title, description: $description, version: $version, status: $status){ | ||
id | ||
version | ||
title | ||
description | ||
status | ||
creationMetadata{ | ||
createdDate | ||
createdBy{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
} | ||
} | ||
assignedTo{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
offix/src/main/graphql/org.aerogear.offix/createTask.graphql
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,31 @@ | ||
mutation createTask($input: TaskInput!){ | ||
createTask(input: $input){ | ||
id | ||
version | ||
title | ||
description | ||
status | ||
creationMetadata{ | ||
createdDate | ||
taskId | ||
createdBy{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} | ||
assignedTo{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
offix/src/main/graphql/org.aerogear.offix/createUser.graphql
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,11 @@ | ||
mutation createUser($input: UserInput!){ | ||
createUser(input: $input){ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
offix/src/main/graphql/org.aerogear.offix/findAllTasks.graphql
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,31 @@ | ||
query findAllTasks{ | ||
findAllTasks{ | ||
id | ||
version | ||
title | ||
description | ||
status | ||
creationMetadata{ | ||
createdDate | ||
taskId | ||
createdBy{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} | ||
assignedTo{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
offix/src/main/graphql/org.aerogear.offix/findAllUsers.graphql
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,11 @@ | ||
query findAllUsers{ | ||
findAllUsers{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
offix/src/main/graphql/org.aerogear.offix/findUsers.graphql
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,11 @@ | ||
query findUsers($fields: UserFilter!){ | ||
findUsers(fields: $fields){ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} |
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,31 @@ | ||
subscription newTask{ | ||
newTask{ | ||
id | ||
version | ||
title | ||
description | ||
status | ||
creationMetadata{ | ||
createdDate | ||
taskId | ||
createdBy{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} | ||
assignedTo{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} | ||
} |
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,11 @@ | ||
subscription newUser{ | ||
newUser{ | ||
id | ||
firstName | ||
lastName | ||
title | ||
taskId | ||
creationmetadataId | ||
} | ||
} |
Oops, something went wrong.