From b9ec548690acf34d520ffc3896a5ccaa8cc639bf Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Mon, 2 Apr 2018 17:34:17 +1000 Subject: [PATCH 01/10] Bump dependency and tools versions --- .gitignore | 34 +-- .idea/.name | 1 - .idea/codeStyleSettings.xml | 280 ------------------ .idea/codeStyles/Project.xml | 61 ++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/compiler.xml | 22 -- .idea/copyright/profiles_settings.xml | 3 - .idea/encodings.xml | 6 - .idea/inspectionProfiles/Project_Default.xml | 9 - .../inspectionProfiles/profiles_settings.xml | 7 - .idea/vcs.xml | 2 +- build.gradle | 10 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 13 files changed, 87 insertions(+), 357 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/codeStyleSettings.xml create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml diff --git a/.gitignore b/.gitignore index c027320..72300e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,15 @@ -# Built application files -*.apk -*.ap_ -# Files for the Dalvik VM -*.dex -# Java class files -*.class +local.properties + # Generated files -bin/ -gen/ -# Gradle files -.gradle/ build/ -# Local configuration file (sdk path, etc) -local.properties -# Proguard folder generated by Eclipse -proguard/ -# Log Files -*.log -.gradle -/local.properties + +# Mac store .DS_Store -/build -*.iml + +# Gradle files +.gradle/ + +/captures # Log Files *.log @@ -41,3 +29,7 @@ proguard/ **/.idea/libraries **/.idea/dictionaries **/.idea/runConfigurations.xml +**/.idea/caches + +# layout inspector view captures +captures \ No newline at end of file diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index fc9365c..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -hawk \ No newline at end of file diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml deleted file mode 100644 index 76534c4..0000000 --- a/.idea/codeStyleSettings.xml +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..f505177 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index ecd817f..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 3b31283..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index efddefc..ec1d645 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ subprojects { project -> jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.1' + classpath 'com.android.tools.build:gradle:3.1.0' } } @@ -37,15 +37,15 @@ subprojects { project -> ext { minSdkVersion = 10 - targetSdkVersion = 24 - compileSdkVersion = 24 - buildToolsVersion = '24.0.2' + targetSdkVersion = 27 + compileSdkVersion = 27 + buildToolsVersion = '27.0.3' sourceCompatibilityVersion = JavaVersion.VERSION_1_7 targetCompatibilityVersion = JavaVersion.VERSION_1_7 } ext.deps = [ - gson : 'com.google.code.gson:gson:2.4', + gson : 'com.google.code.gson:gson:2.8.2', conceal : 'com.facebook.conceal:conceal:1.1.3@aar', // Test dependencies diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 191af49..ed805a8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Aug 26 22:12:19 CEST 2016 +#Mon Apr 02 17:27:38 AEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip From ec1d24de48c3ac10b9230e70ee1ec97b95cd2690 Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Mon, 2 Apr 2018 17:34:51 +1000 Subject: [PATCH 02/10] Update Travis for new tools --- .travis.yml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8f3f9e..8bbde27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,15 @@ language: android +jdk: oraclejdk8 android: components: - tools - platform-tools - - build-tools-24.0.2 - - android-24 - - extra-android-m2repository - - sys-img-armeabi-v7a-android-18 + - build-tools-27.0.3 + - android-27 -jdk: - - oraclejdk8 - -notifications: - email: false +before_install: + - yes | sdkmanager "platforms;android-27" script: -- ./gradlew check - -cache: - directories: - - $HOME/.m2 - - $HOME/.gradle \ No newline at end of file +- ./gradlew check \ No newline at end of file From cf52ec10b61cb6abcfb7fbca549cce656d9741c8 Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Mon, 2 Apr 2018 20:04:50 +1000 Subject: [PATCH 03/10] Update javadocs to add missing information --- .idea/codeStyles/Project.xml | 1 + .../java/com/orhanobut/hawk/Converter.java | 11 +++++--- .../java/com/orhanobut/hawk/Encryption.java | 9 +++++-- .../main/java/com/orhanobut/hawk/Hawk.java | 9 +++---- .../main/java/com/orhanobut/hawk/Parser.java | 25 ++++++++++++++++++- .../java/com/orhanobut/hawk/Serializer.java | 8 +++++- .../main/java/com/orhanobut/hawk/Storage.java | 8 +++++- 7 files changed, 56 insertions(+), 15 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index f505177..b983ffe 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -2,6 +2,7 @@ diff --git a/hawk/src/main/java/com/orhanobut/hawk/Converter.java b/hawk/src/main/java/com/orhanobut/hawk/Converter.java index 56b3c00..88c0d26 100644 --- a/hawk/src/main/java/com/orhanobut/hawk/Converter.java +++ b/hawk/src/main/java/com/orhanobut/hawk/Converter.java @@ -1,12 +1,17 @@ package com.orhanobut.hawk; -interface Converter { +/** + * Used to handle encoding and decoding as an intermediate layer. + *

Implement this interface if a custom implementation is needed

+ * + * @see HawkConverter + */ +public interface Converter { /** * Encodes the value * * @param value will be encoded - * * @return the encoded string */ String toString(T value); @@ -15,9 +20,7 @@ interface Converter { * Decodes * * @param value is the encoded data - * * @return the plain value - * * @throws Exception */ T fromString(String value, DataInfo dataInfo) throws Exception; diff --git a/hawk/src/main/java/com/orhanobut/hawk/Encryption.java b/hawk/src/main/java/com/orhanobut/hawk/Encryption.java index c98c321..cb78918 100644 --- a/hawk/src/main/java/com/orhanobut/hawk/Encryption.java +++ b/hawk/src/main/java/com/orhanobut/hawk/Encryption.java @@ -1,5 +1,12 @@ package com.orhanobut.hawk; +/** + * Intermediate layer which is used by Hawk to encrypt and decrypt the given values. + * + *

Use custom implementation if built-in implementation is not enough.

+ * + * @see ConcealEncryption + */ public interface Encryption { /** @@ -15,7 +22,6 @@ public interface Encryption { * * @param key is the given key * @param value is the plain text - * * @return cipher text as string */ String encrypt(String key, String value) throws Exception; @@ -25,7 +31,6 @@ public interface Encryption { * * @param key is the given key * @param value is the cipher text - * * @return plain text */ String decrypt(String key, String value) throws Exception; diff --git a/hawk/src/main/java/com/orhanobut/hawk/Hawk.java b/hawk/src/main/java/com/orhanobut/hawk/Hawk.java index 35e8b46..c01faa9 100644 --- a/hawk/src/main/java/com/orhanobut/hawk/Hawk.java +++ b/hawk/src/main/java/com/orhanobut/hawk/Hawk.java @@ -2,7 +2,9 @@ import android.content.Context; - +/** + * Secure, simple key-value storage for Android. + */ public final class Hawk { private Hawk() { @@ -32,7 +34,6 @@ static void build(HawkBuilder hawkBuilder) { * * @param key is required to differentiate the given data * @param value is the data that is going to be encrypted and persisted - * * @return true if the operation is successful. Any failure in any step will return false */ public static boolean put(String key, T value) { @@ -45,7 +46,6 @@ public static boolean put(String key, T value) { * data type might affect the result. It's guaranteed to return primitive types and String type * * @param key is used to get the persisted data - * * @return the original object */ public static T get(String key) { @@ -57,7 +57,6 @@ public static T get(String key) { * * @param key is used to get the saved data * @param defaultValue will be return if the response is null - * * @return the saved object */ public static T get(String key, T defaultValue) { @@ -87,7 +86,6 @@ public static boolean deleteAll() { * Removes the given key/value from the storage * * @param key is used for removing related data from storage - * * @return true if delete is successful */ public static boolean delete(String key) { @@ -98,7 +96,6 @@ public static boolean delete(String key) { * Checks the given key whether it exists or not * * @param key is the key to check - * * @return true if it exists in the storage */ public static boolean contains(String key) { diff --git a/hawk/src/main/java/com/orhanobut/hawk/Parser.java b/hawk/src/main/java/com/orhanobut/hawk/Parser.java index d95854e..d9e783a 100644 --- a/hawk/src/main/java/com/orhanobut/hawk/Parser.java +++ b/hawk/src/main/java/com/orhanobut/hawk/Parser.java @@ -2,11 +2,34 @@ import java.lang.reflect.Type; -@SuppressWarnings("WeakerAccess") +/** + * Intermediate layer that handles serialization/deserialization for the end result. + * This is not the same as {@link Serializer}. This interface is only used to convert the intermediate value into String, + * or vice-versa to be used for {@link Storage} + * + *

Use custom implementation if built-in implementation is not enough.

+ * + * @see GsonParser + */ public interface Parser { + /** + * Deserialize the given text for the given type and returns it. + * + * @param content is the value that will be deserialized. + * @param type is the object type which value will be converted to. + * @param is the expected type. + * @return the expected type. + * @throws Exception if the operation is not successful. + */ T fromJson(String content, Type type) throws Exception; + /** + * Serialize the given object to String. + * + * @param body is the object that will be serialized. + * @return the serialized text. + */ String toJson(Object body); } diff --git a/hawk/src/main/java/com/orhanobut/hawk/Serializer.java b/hawk/src/main/java/com/orhanobut/hawk/Serializer.java index 8fe44f6..bd9ccf2 100644 --- a/hawk/src/main/java/com/orhanobut/hawk/Serializer.java +++ b/hawk/src/main/java/com/orhanobut/hawk/Serializer.java @@ -1,6 +1,12 @@ package com.orhanobut.hawk; -@SuppressWarnings("WeakerAccess") +/** + * Intermediate layer that is used to serialize/deserialize the cipher text + * + *

Use custom implementation if built-in implementation is not enough.

+ * + * @see HawkSerializer + */ public interface Serializer { /** diff --git a/hawk/src/main/java/com/orhanobut/hawk/Storage.java b/hawk/src/main/java/com/orhanobut/hawk/Storage.java index bfad5cc..9d789d5 100644 --- a/hawk/src/main/java/com/orhanobut/hawk/Storage.java +++ b/hawk/src/main/java/com/orhanobut/hawk/Storage.java @@ -1,6 +1,12 @@ package com.orhanobut.hawk; -@SuppressWarnings("WeakerAccess") +/** + * Intermediate layer which stores the given data. Used by Hawk. + * + *

Use custom implementation if the built-in implementations are not enough.

+ * + * @see SharedPreferencesStorage + */ public interface Storage { /** From a869d812f0d8f55a384e9801f14fe1fc3e56f8b6 Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Mon, 2 Apr 2018 20:39:23 +1000 Subject: [PATCH 04/10] Bump min sdk to 15 --- benchmark/build.gradle | 9 +++------ build.gradle | 4 ++-- hawk/build.gradle | 20 ++++++++------------ 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/benchmark/build.gradle b/benchmark/build.gradle index 482abcd..dbce8d2 100644 --- a/benchmark/build.gradle +++ b/benchmark/build.gradle @@ -7,7 +7,7 @@ android { defaultConfig { applicationId "com.orhanobut.benchmark" minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion + targetSdkVersion 26 versionCode 1 versionName "1.0" } @@ -20,9 +20,6 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:24.2.1' - - compile project(':hawk') + implementation 'com.android.support:appcompat-v7:27.1.0' + implementation project(':hawk') } diff --git a/build.gradle b/build.gradle index ec1d645..35c0919 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ subprojects { project -> } ext { - minSdkVersion = 10 + minSdkVersion = 15 targetSdkVersion = 27 compileSdkVersion = 27 buildToolsVersion = '27.0.3' @@ -51,7 +51,7 @@ ext.deps = [ // Test dependencies junit : 'junit:junit:4.12', truth : 'com.google.truth:truth:0.28', - robolectric : 'org.robolectric:robolectric:3.1.2', + robolectric : 'org.robolectric:robolectric:3.3', mockito : 'org.mockito:mockito-core:1.10.19', espressoRunner: 'com.android.support.test:runner:0.5', espressoRules : 'com.android.support.test:rules:0.5' diff --git a/hawk/build.gradle b/hawk/build.gradle index 69f654b..a728c5d 100644 --- a/hawk/build.gradle +++ b/hawk/build.gradle @@ -17,20 +17,16 @@ android { } dependencies { - compile deps.gson - compile deps.conceal + api deps.conceal + implementation deps.gson - testCompile deps.junit - testCompile deps.truth - testCompile deps.robolectric - testCompile deps.mockito - - androidTestCompile deps.junit - androidTestCompile deps.truth - - androidTestCompile deps.espressoRunner - androidTestCompile deps.espressoRules + testImplementation deps.junit + testImplementation deps.truth + testImplementation deps.robolectric + testImplementation deps.mockito + androidTestImplementation deps.junit + androidTestImplementation deps.truth } apply from: rootProject.file('gradle/maven_push.gradle') \ No newline at end of file From 7fe2699b71c971440e74598d7a080ed42eeadcb7 Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Mon, 2 Apr 2018 20:41:16 +1000 Subject: [PATCH 05/10] Remove redundant Robolectric config field from tests. --- hawk/build.gradle | 2 ++ hawk/src/test/java/com/orhanobut/hawk/HawkBuilderTest.java | 1 - hawk/src/test/java/com/orhanobut/hawk/HawkConverterTest.java | 1 - .../test/java/com/orhanobut/hawk/HawkFacadeIntegrationTest.java | 1 - hawk/src/test/java/com/orhanobut/hawk/HawkUtilsTest.java | 1 - hawk/src/test/java/com/orhanobut/hawk/NoEncryptionTest.java | 1 - .../java/com/orhanobut/hawk/SharedPreferencesStorageTest.java | 1 - 7 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hawk/build.gradle b/hawk/build.gradle index a728c5d..4c85198 100644 --- a/hawk/build.gradle +++ b/hawk/build.gradle @@ -27,6 +27,8 @@ dependencies { androidTestImplementation deps.junit androidTestImplementation deps.truth + androidTestImplementation deps.espressoRunner + androidTestImplementation deps.espressoRules } apply from: rootProject.file('gradle/maven_push.gradle') \ No newline at end of file diff --git a/hawk/src/test/java/com/orhanobut/hawk/HawkBuilderTest.java b/hawk/src/test/java/com/orhanobut/hawk/HawkBuilderTest.java index bd0c252..2c2d8af 100644 --- a/hawk/src/test/java/com/orhanobut/hawk/HawkBuilderTest.java +++ b/hawk/src/test/java/com/orhanobut/hawk/HawkBuilderTest.java @@ -14,7 +14,6 @@ import static org.mockito.MockitoAnnotations.initMocks; @RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 21) public class HawkBuilderTest { private HawkBuilder builder; diff --git a/hawk/src/test/java/com/orhanobut/hawk/HawkConverterTest.java b/hawk/src/test/java/com/orhanobut/hawk/HawkConverterTest.java index 1f157e9..46d7266 100644 --- a/hawk/src/test/java/com/orhanobut/hawk/HawkConverterTest.java +++ b/hawk/src/test/java/com/orhanobut/hawk/HawkConverterTest.java @@ -19,7 +19,6 @@ import static junit.framework.Assert.fail; @RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 18) public class HawkConverterTest { private Converter converter; diff --git a/hawk/src/test/java/com/orhanobut/hawk/HawkFacadeIntegrationTest.java b/hawk/src/test/java/com/orhanobut/hawk/HawkFacadeIntegrationTest.java index c30904f..c4a22bd 100644 --- a/hawk/src/test/java/com/orhanobut/hawk/HawkFacadeIntegrationTest.java +++ b/hawk/src/test/java/com/orhanobut/hawk/HawkFacadeIntegrationTest.java @@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat; @RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 21) public class HawkFacadeIntegrationTest { @Before public void setUp() { diff --git a/hawk/src/test/java/com/orhanobut/hawk/HawkUtilsTest.java b/hawk/src/test/java/com/orhanobut/hawk/HawkUtilsTest.java index 7d5382f..f199555 100644 --- a/hawk/src/test/java/com/orhanobut/hawk/HawkUtilsTest.java +++ b/hawk/src/test/java/com/orhanobut/hawk/HawkUtilsTest.java @@ -10,7 +10,6 @@ @RunWith(RobolectricTestRunner.class) -@Config(sdk = 21, constants = BuildConfig.class) public class HawkUtilsTest { @Test public void checkNullShouldDoNothing() { diff --git a/hawk/src/test/java/com/orhanobut/hawk/NoEncryptionTest.java b/hawk/src/test/java/com/orhanobut/hawk/NoEncryptionTest.java index 261d875..48e2001 100644 --- a/hawk/src/test/java/com/orhanobut/hawk/NoEncryptionTest.java +++ b/hawk/src/test/java/com/orhanobut/hawk/NoEncryptionTest.java @@ -15,7 +15,6 @@ import static org.mockito.MockitoAnnotations.initMocks; @RunWith(RobolectricTestRunner.class) -@Config(sdk = 21, constants = BuildConfig.class) public class NoEncryptionTest { @Spy NoEncryption encryption; diff --git a/hawk/src/test/java/com/orhanobut/hawk/SharedPreferencesStorageTest.java b/hawk/src/test/java/com/orhanobut/hawk/SharedPreferencesStorageTest.java index 4083c6e..8ba2ff9 100644 --- a/hawk/src/test/java/com/orhanobut/hawk/SharedPreferencesStorageTest.java +++ b/hawk/src/test/java/com/orhanobut/hawk/SharedPreferencesStorageTest.java @@ -18,7 +18,6 @@ import static org.mockito.Mockito.verify; @RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) public class SharedPreferencesStorageTest { private SharedPreferencesStorage storage; From 71b3dee7e2647e972c102b8dab91fc1245ffaa30 Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Mon, 2 Apr 2018 20:45:25 +1000 Subject: [PATCH 06/10] Add Kotlin for tests --- build.gradle | 39 +++++++++++++++++++++++++-------------- hawk/build.gradle | 2 ++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 35c0919..bb026c7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,22 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlinVersion = '1.2.31' + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + subprojects { project -> group = GROUP version = VERSION_NAME @@ -20,19 +38,10 @@ subprojects { project -> check.dependsOn('checkstyle') } } +} - buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.1.0' - } - } - - repositories { - jcenter() - } +task clean(type: Delete) { + delete rootProject.buildDir } ext { @@ -54,5 +63,7 @@ ext.deps = [ robolectric : 'org.robolectric:robolectric:3.3', mockito : 'org.mockito:mockito-core:1.10.19', espressoRunner: 'com.android.support.test:runner:0.5', - espressoRules : 'com.android.support.test:rules:0.5' + espressoRules : 'com.android.support.test:rules:0.5', + kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" + ] diff --git a/hawk/build.gradle b/hawk/build.gradle index 4c85198..2bc8c42 100644 --- a/hawk/build.gradle +++ b/hawk/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.ext.compileSdkVersion @@ -24,6 +25,7 @@ dependencies { testImplementation deps.truth testImplementation deps.robolectric testImplementation deps.mockito + testImplementation deps.kotlin androidTestImplementation deps.junit androidTestImplementation deps.truth From 1c498eb6733f1d77ce735bbe78003249fc30eccd Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Mon, 2 Apr 2018 21:02:00 +1000 Subject: [PATCH 07/10] Convert all tests to Kotlin --- .idea/codeStyles/Project.xml | 2 + build.gradle | 2 +- hawk/build.gradle | 2 + .../orhanobut/hawk/ConcealEncryptionTest.java | 35 --- .../orhanobut/hawk/ConcealEncryptionTest.kt | 35 +++ .../java/com/orhanobut/hawk/ConcealTest.java | 45 ---- .../java/com/orhanobut/hawk/ConcealTest.kt | 40 +++ .../orhanobut/hawk/DefaultHawkFacadeTest.java | 239 ----------------- .../orhanobut/hawk/DefaultHawkFacadeTest.kt | 243 ++++++++++++++++++ .../orhanobut/hawk/EmptyHawkFacadeTest.java | 83 ------ .../com/orhanobut/hawk/EmptyHawkFacadeTest.kt | 89 +++++++ .../test/java/com/orhanobut/hawk/FooBar.java | 9 - .../test/java/com/orhanobut/hawk/FooBar.kt | 9 + .../com/orhanobut/hawk/HawkBuilderTest.java | 157 ----------- .../com/orhanobut/hawk/HawkBuilderTest.kt | 162 ++++++++++++ .../com/orhanobut/hawk/HawkConverterTest.java | 116 --------- .../com/orhanobut/hawk/HawkConverterTest.kt | 114 ++++++++ .../hawk/HawkFacadeIntegrationTest.java | 4 +- .../orhanobut/hawk/HawkSerializerTest.java | 159 ------------ .../com/orhanobut/hawk/HawkSerializerTest.kt | 151 +++++++++++ .../java/com/orhanobut/hawk/HawkTest.java | 87 ------- .../test/java/com/orhanobut/hawk/HawkTest.kt | 84 ++++++ .../com/orhanobut/hawk/HawkUtilsTest.java | 55 ---- .../java/com/orhanobut/hawk/HawkUtilsTest.kt | 54 ++++ .../com/orhanobut/hawk/NoEncryptionTest.java | 61 ----- .../com/orhanobut/hawk/NoEncryptionTest.kt | 61 +++++ .../hawk/SharedPreferencesStorageTest.java | 169 ------------ .../hawk/SharedPreferencesStorageTest.kt | 167 ++++++++++++ .../org.mockito.plugins.MockMaker | 1 + 29 files changed, 1217 insertions(+), 1218 deletions(-) delete mode 100644 hawk/src/androidTest/java/com/orhanobut/hawk/ConcealEncryptionTest.java create mode 100644 hawk/src/androidTest/java/com/orhanobut/hawk/ConcealEncryptionTest.kt delete mode 100644 hawk/src/androidTest/java/com/orhanobut/hawk/ConcealTest.java create mode 100644 hawk/src/androidTest/java/com/orhanobut/hawk/ConcealTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/DefaultHawkFacadeTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/DefaultHawkFacadeTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/EmptyHawkFacadeTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/EmptyHawkFacadeTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/FooBar.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/FooBar.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkBuilderTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkBuilderTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkConverterTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkConverterTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkSerializerTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkSerializerTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkUtilsTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/HawkUtilsTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/NoEncryptionTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/NoEncryptionTest.kt delete mode 100644 hawk/src/test/java/com/orhanobut/hawk/SharedPreferencesStorageTest.java create mode 100644 hawk/src/test/java/com/orhanobut/hawk/SharedPreferencesStorageTest.kt create mode 100644 hawk/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index b983ffe..8c95146 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -52,6 +52,8 @@ +