Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
0.0.5
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ricardobrg authored Dec 22, 2022
2 parents ea23e4e + efe28d9 commit 2f74707
Show file tree
Hide file tree
Showing 37 changed files with 1,236 additions and 263 deletions.
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext.flutterEngine = "1.0.0-857bd6b74c5eb56151bfafe91e7fa6a82b6fee25"
ext.sdkVersion = "0.0.19"
ext.flutterEngine = "1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99"
ext.sdkVersion = "0.0.23"
repositories {
mavenCentral()
}
Expand Down Expand Up @@ -49,9 +49,13 @@ android {
}

apply plugin: 'com.kezong.fat-aar'
apply plugin: 'kotlin-kapt'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.core:core-ktx:1.9.0'
implementation("com.squareup.moshi:moshi-kotlin:1.14.0")
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.14.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
Expand Down
97 changes: 44 additions & 53 deletions app/src/androidTest/java/com/mytiki/tiki_sdk_android/TikiSdkTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ package com.mytiki.tiki_sdk_android

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import kotlinx.coroutines.*
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.After
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

Expand All @@ -18,70 +12,67 @@ const val ORIGIN: String = "com.mytiki.tiki_sdk_android.test"
@RunWith(AndroidJUnit4::class)
class TikiSdkTest {

val callback = {
response: String -> print(response)
@Test
fun init_tiki_sdk() {
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
assert(tikiSdk.address.length > 32)
}

@Test
fun init_tiki_sdk() {
getInstrumentation().runOnMainSync {
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
Assert.assertNotNull(tikiSdk)
}
fun init_tiki_sdk_with_address() {
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
val address = tikiSdk.address
val tikiSdk2 = TikiSdk(API_KEY, ORIGIN, context, address)
assertEquals(tikiSdk.address, tikiSdk2.address)
}

@Test
fun assign_onwership() {
getInstrumentation().runOnMainSync {
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
tikiSdk.assignOwnership(
"com.mytiki.androidtest",
"data_point", callback, listOf("nothing")
)
}
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
val ownershipId = tikiSdk.assignOwnership("source", TikiSdkDataTypeEnum.data_point, listOf("test"))
assert(ownershipId.length > 32)
}

@Test
fun give_consent() {
getInstrumentation().runOnMainSync {
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(ORIGIN, API_KEY, context)
tikiSdk.assignOwnership("com.mytiki.test", "pool")
tikiSdk.modifyConsent("com.mytiki.test", TikiSdkDestination(listOf("*"), listOf("*")),)
assertEquals(1, 1)
}
fun get_onwership() {
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
val ownershipId = tikiSdk.assignOwnership("source", TikiSdkDataTypeEnum.data_point, listOf("test"))
val ownership = tikiSdk.getOwnership("source")
assertEquals(ownershipId, ownership!!.transactionId)
}

@Test
fun modify_consent() {
getInstrumentation().runOnMainSync {
val context = getInstrumentation().targetContext
val sdk = TikiSdk(API_KEY, ORIGIN, context)
sdk.assignOwnership("com.mytiki.test", "pool")
sdk.modifyConsent("com.mytiki.test", TikiSdkDestination(listOf("*"), listOf("*")))
sdk.modifyConsent("com.mytiki.test", TikiSdkDestination(listOf(), listOf()))
assertEquals(1, 1)
}
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
val ownershipId = tikiSdk.assignOwnership("source", TikiSdkDataTypeEnum.data_point, listOf("test"))
val consent = tikiSdk.modifyConsent(ownershipId, TikiSdkDestination.ALL)
assertEquals(consent.ownershipId, ownershipId)
}

fun get_consent() {
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
val ownershipId = tikiSdk.assignOwnership("source", TikiSdkDataTypeEnum.data_point, listOf("test"))
val consent = tikiSdk.modifyConsent(ownershipId, TikiSdkDestination.ALL)
val consentGet = tikiSdk.getConsent("source")
assertEquals(consent.transactionId, consentGet!!.transactionId)
}

@Test
fun apply_consent() {
getInstrumentation().runOnMainSync {
var ok = false
val context = getInstrumentation().targetContext
val sdk = TikiSdk(API_KEY, ORIGIN, context)
sdk.assignOwnership("com.mytiki.test", "pool")
sdk.modifyConsent("com.mytiki.test", TikiSdkDestination(listOf("*"), listOf("*")))
sdk.applyConsent("com.mytiki.test", TikiSdkDestination(listOf("*"), listOf("*")),
{
ok = true
},
{
ok = false
})
Thread.sleep(1000)
}
val context = getInstrumentation().targetContext
val tikiSdk = TikiSdk(API_KEY, ORIGIN, context)
val ownershipId = tikiSdk.assignOwnership("source", TikiSdkDataTypeEnum.data_point, listOf("test"))
tikiSdk.modifyConsent(ownershipId, TikiSdkDestination.ALL)
var ok = false
tikiSdk.applyConsent("source", TikiSdkDestination.ALL, {
ok = true
})
assert(ok)
}
}
Loading

0 comments on commit 2f74707

Please sign in to comment.