From f8576f2af70a5cdaf3abe33172a4a3d79160c2d3 Mon Sep 17 00:00:00 2001 From: Ilya Zorin Date: Sat, 4 Feb 2017 18:02:01 +0200 Subject: [PATCH 01/11] Tests for error cases in StorIOSQLiteAnnotationsProcessor --- build.gradle | 1 + settings.gradle | 2 +- .../processor/StorIOAnnotationsProcessor.java | 105 +++--- .../.gitignore | 1 + .../build.gradle | 21 ++ .../build.workaround-missing-resource.gradle | 23 ++ .../proguard-rules.pro | 17 + .../src/main/AndroidManifest.xml | 11 + .../src/main/res/values/strings.xml | 3 + .../StorIOSQLiteAnnotationsProcessorTest.java | 300 ++++++++++++++++++ ...AnnotatedFieldInsideNotAnnotatedClass.java | 7 + .../AnnotatedFieldNotInsideClass.java | 7 + .../test/resources/AnnotatedInterface.java | 6 + .../CreatorInsideNotAnnotatedClass.java | 7 + .../CreatorMethodWithDifferentReturnType.java | 8 + .../test/resources/CreatorNotInsideClass.java | 7 + .../CreatorWithWrongNumberOfArguments.java | 11 + .../src/test/resources/EmptyClass.java | 6 + .../src/test/resources/EmptyColumnName.java | 8 + .../src/test/resources/EmptyTable.java | 8 + .../src/test/resources/FinalField.java | 8 + .../test/resources/IgnoreNullOnPrimitive.java | 8 + .../test/resources/MethodWithParameters.java | 10 + .../test/resources/MixedFieldsAndMethods.java | 11 + .../src/test/resources/MultipleCreators.java | 11 + .../src/test/resources/NoCreator.java | 8 + .../src/test/resources/NoKey.java | 8 + .../resources/NonStaticCreatorMethod.java | 8 + .../src/test/resources/PrivateClass.java | 17 + .../src/test/resources/PrivateCreator.java | 8 + .../src/test/resources/PrivateField.java | 8 + .../src/test/resources/SameColumnName.java | 11 + .../src/test/resources/UnsupportedType.java | 15 + .../processor/StorIOSQLiteProcessor.java | 95 +++--- 34 files changed, 700 insertions(+), 85 deletions(-) create mode 100644 storio-sqlite-annotations-processor-test/.gitignore create mode 100644 storio-sqlite-annotations-processor-test/build.gradle create mode 100644 storio-sqlite-annotations-processor-test/build.workaround-missing-resource.gradle create mode 100644 storio-sqlite-annotations-processor-test/proguard-rules.pro create mode 100644 storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml create mode 100644 storio-sqlite-annotations-processor-test/src/main/res/values/strings.xml create mode 100644 storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldInsideNotAnnotatedClass.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldNotInsideClass.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedInterface.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/CreatorNotInsideClass.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/EmptyClass.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/EmptyColumnName.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/EmptyTable.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/FinalField.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/IgnoreNullOnPrimitive.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/NoKey.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrivateClass.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrivateField.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/SameColumnName.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/UnsupportedType.java diff --git a/build.gradle b/build.gradle index babd15484..3d4242977 100644 --- a/build.gradle +++ b/build.gradle @@ -72,6 +72,7 @@ ext.libraries = [ privateConstructorChecker : 'com.pushtorefresh.java-private-constructor-checker:checker:1.1.0', guava : 'com.google.guava:guava:18.0', robolectric : 'org.robolectric:robolectric:3.1.4', + googleTestingCompile : 'com.google.testing.compile:compile-testing:0.10', dagger : 'com.google.dagger:dagger:' + daggerVersion, daggerCompiler : 'com.google.dagger:dagger-compiler:' + daggerVersion, diff --git a/settings.gradle b/settings.gradle index 222d1fbd4..531a8ea7c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include ':storio-common' +include ':storio-common', ':storio-sqlite-annotations-processor-test' include ':storio-test-common' include ':storio-sqlite' include ':storio-content-resolver' diff --git a/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java b/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java index a246c939a..fab299d24 100644 --- a/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java +++ b/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java @@ -59,7 +59,8 @@ public abstract class StorIOAnnotationsProcessor * @return non-null unmodifiable map(element, typeMeta) */ @NotNull - private Map processAnnotatedClasses(@NotNull final RoundEnvironment roundEnvironment, @NotNull final Elements elementUtils) { + private Map processAnnotatedClasses(@NotNull final RoundEnvironment roundEnvironment, + @NotNull final Elements elementUtils) { final Set elementsAnnotatedWithStorIOType = roundEnvironment.getElementsAnnotatedWith(getTypeAnnotationClass()); @@ -87,9 +88,18 @@ private TypeElement validateAnnotatedClass(@NotNull final Element annotatedEleme final TypeElement annotatedTypeElement = (TypeElement) annotatedElement; if (annotatedTypeElement.getModifiers().contains(PRIVATE)) { - throw new ProcessingException( - annotatedElement, - getTypeAnnotationClass().getSimpleName() + " can not be applied to private class: " + annotatedTypeElement.getQualifiedName() + throw new ProcessingException(annotatedElement, + getTypeAnnotationClass().getSimpleName() + + " can not be applied to private class: " + + annotatedTypeElement.getSimpleName() + ); + } + + if (annotatedTypeElement.getKind() != CLASS) { + throw new ProcessingException(annotatedElement, + getTypeAnnotationClass().getSimpleName() + + " can be applied only to classes not to " + + annotatedTypeElement.getSimpleName() ); } @@ -108,43 +118,53 @@ protected void validateAnnotatedFieldOrMethod(@NotNull final Element annotatedEl final Element enclosingElement = annotatedElement.getEnclosingElement(); if (enclosingElement.getKind() != CLASS) { - throw new ProcessingException( - annotatedElement, - "Please apply " + getColumnAnnotationClass().getSimpleName() + " to fields or methods of class: " + annotatedElement.getSimpleName() + throw new ProcessingException(annotatedElement, + "Please apply " + + getColumnAnnotationClass().getSimpleName() + + " only to members of class (fields or methods) - not to members of " + + enclosingElement.getSimpleName() ); } if (enclosingElement.getAnnotation(getTypeAnnotationClass()) == null) { Element superClass = typeUtils.asElement(((TypeElement) enclosingElement).getSuperclass()); if (superClass.getAnnotation(getTypeAnnotationClass()) != null) { - throw new SkipNotAnnotatedClassWithAnnotatedParentException("Fields of classes not annotated with" + getTypeAnnotationClass().getSimpleName() + - "which have parents annotated with" + getTypeAnnotationClass().getSimpleName() + "will be skipped (e.g. AutoValue case)"); + throw new SkipNotAnnotatedClassWithAnnotatedParentException("Fields of classes not annotated with" + + getTypeAnnotationClass().getSimpleName() + + "which have parents annotated with" + + getTypeAnnotationClass().getSimpleName() + + "will be skipped (e.g. AutoValue case)"); } else { - throw new ProcessingException( - annotatedElement, - "Please annotate class " + enclosingElement.getSimpleName() + " with " + getTypeAnnotationClass().getSimpleName() + throw new ProcessingException(annotatedElement, + "Please annotate class " + + enclosingElement.getSimpleName() + + " with " + + getTypeAnnotationClass().getSimpleName() ); } } if (annotatedElement.getModifiers().contains(PRIVATE)) { - throw new ProcessingException( - annotatedElement, - getColumnAnnotationClass().getSimpleName() + " can not be applied to private field or method: " + annotatedElement.getSimpleName() + throw new ProcessingException(annotatedElement, + getColumnAnnotationClass().getSimpleName() + + " can not be applied to private field or method: " + + annotatedElement.getSimpleName() ); } if (annotatedElement.getKind() == FIELD && annotatedElement.getModifiers().contains(FINAL)) { - throw new ProcessingException( - annotatedElement, - getColumnAnnotationClass().getSimpleName() + " can not be applied to final field: " + annotatedElement.getSimpleName() + throw new ProcessingException(annotatedElement, + getColumnAnnotationClass().getSimpleName() + + " can not be applied to final field: " + + annotatedElement.getSimpleName() ); } if (annotatedElement.getKind() == METHOD && !((ExecutableElement) annotatedElement).getParameters().isEmpty()) { - throw new ProcessingException( - annotatedElement, - getColumnAnnotationClass().getSimpleName() + " can not be applied to method with parameters: " + annotatedElement.getSimpleName() + throw new ProcessingException(annotatedElement, + getColumnAnnotationClass().getSimpleName() + + " can not be applied to method with parameters: " + + annotatedElement.getSimpleName() ); } } @@ -160,37 +180,44 @@ protected void validateAnnotatedExecutable(@NotNull final ExecutableElement anno final Element enclosingElement = annotatedElement.getEnclosingElement(); if (enclosingElement.getKind() != CLASS) { - throw new ProcessingException( - annotatedElement, - "Please apply " + getCreatorAnnotationClass().getSimpleName() + " to constructor or factory method of class: " + enclosingElement.getSimpleName() + throw new ProcessingException(annotatedElement, + "Please apply " + + getCreatorAnnotationClass().getSimpleName() + + " to constructor or factory method of class - not to " + + enclosingElement.getSimpleName() ); } if (enclosingElement.getAnnotation(getTypeAnnotationClass()) == null) { - throw new ProcessingException( - annotatedElement, - "Please annotate class " + enclosingElement.getSimpleName() + " with " + getTypeAnnotationClass().getSimpleName() + throw new ProcessingException(annotatedElement, + "Please annotate class " + + enclosingElement.getSimpleName() + + " with " + + getTypeAnnotationClass().getSimpleName() ); } if (annotatedElement.getModifiers().contains(PRIVATE)) { - throw new ProcessingException( - annotatedElement, - getCreatorAnnotationClass().getSimpleName() + " can not be applied to private methods or constructors: " + annotatedElement.getSimpleName() + throw new ProcessingException(annotatedElement, + getCreatorAnnotationClass().getSimpleName() + + " can not be applied to private methods or constructors: " + + annotatedElement.getSimpleName() ); } if (annotatedElement.getKind() == METHOD && !annotatedElement.getModifiers().contains(STATIC)) { - throw new ProcessingException( - annotatedElement, - getCreatorAnnotationClass().getSimpleName() + " can not be applied to non-static methods: " + annotatedElement.getSimpleName() + throw new ProcessingException(annotatedElement, + getCreatorAnnotationClass().getSimpleName() + + " can not be applied to non-static methods: " + + annotatedElement.getSimpleName() ); } if (annotatedElement.getKind() == METHOD && !annotatedElement.getReturnType().equals(enclosingElement.asType())) { - throw new ProcessingException( - annotatedElement, - getCreatorAnnotationClass().getSimpleName() + " can not be applied to method with different return type from: " + enclosingElement.getSimpleName() + throw new ProcessingException(annotatedElement, + getCreatorAnnotationClass().getSimpleName() + + " can not be applied to method with return type different from " + + enclosingElement.getSimpleName() ); } } @@ -267,7 +294,8 @@ public boolean process(@Nullable final Set annotations, @ * @param roundEnvironment current processing environment * @param annotatedClasses map of annotated classes */ - protected abstract void processAnnotatedFieldsOrMethods(@NotNull final RoundEnvironment roundEnvironment, @NotNull Map annotatedClasses); + protected abstract void processAnnotatedFieldsOrMethods(@NotNull final RoundEnvironment roundEnvironment, + @NotNull Map annotatedClasses); /** * Processes annotated field and returns result of processing or throws exception. @@ -284,7 +312,8 @@ public boolean process(@Nullable final Set annotations, @ * @param roundEnvironment current processing environment * @param annotatedClasses map of annotated classes */ - protected abstract void processAnnotatedExecutables(@NotNull final RoundEnvironment roundEnvironment, @NotNull Map annotatedClasses); + protected abstract void processAnnotatedExecutables(@NotNull final RoundEnvironment roundEnvironment, + @NotNull Map annotatedClasses); protected abstract void validateAnnotatedClassesAndColumns(@NotNull Map annotatedClasses); diff --git a/storio-sqlite-annotations-processor-test/.gitignore b/storio-sqlite-annotations-processor-test/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/storio-sqlite-annotations-processor-test/.gitignore @@ -0,0 +1 @@ +/build diff --git a/storio-sqlite-annotations-processor-test/build.gradle b/storio-sqlite-annotations-processor-test/build.gradle new file mode 100644 index 000000000..a3aed3cd5 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/build.gradle @@ -0,0 +1,21 @@ +import org.gradle.internal.jvm.Jvm + +apply plugin: 'com.android.library' +apply from: 'build.workaround-missing-resource.gradle' + +android { + compileSdkVersion rootProject.ext.compileSdkVersion + buildToolsVersion rootProject.ext.buildToolsVersion + + defaultConfig { + minSdkVersion rootProject.ext.minSdkVersion + } +} + +dependencies { + testCompile libraries.storIOSQLite + testCompile libraries.storIOSQLiteAnnotationsProcessor + testCompile libraries.googleTestingCompile + testCompile files(Jvm.current().getRuntimeJar()) + testCompile files(Jvm.current().getToolsJar()) +} diff --git a/storio-sqlite-annotations-processor-test/build.workaround-missing-resource.gradle b/storio-sqlite-annotations-processor-test/build.workaround-missing-resource.gradle new file mode 100644 index 000000000..7637db440 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/build.workaround-missing-resource.gradle @@ -0,0 +1,23 @@ +// Source - https://github.com/nenick/AndroidStudioAndRobolectric/blob/master/app/build.workaround-missing-resource.gradle +// Workaround for missing test resources when running unit tests within android studio. +// This copies the test resources next to the test classes for each variant. +// Tracked at https://github.com/nenick/AndroidStudioAndRobolectric/issues/7 +// Original solution comes from https://code.google.com/p/android/issues/detail?id=136013#c10 +// See also https://code.google.com/p/android/issues/detail?id=64887 +gradle.projectsEvaluated { + // Base path which is recognized by android studio. + def testClassesPath = "${buildDir}/intermediates/classes/test/" + // Copy must be done for each variant. + def variants = android.libraryVariants.collect() + + variants.each { variant -> + def variationName = variant.name.capitalize() + def variationPath = variant.buildType.name + + // Specific copy task for each variant + def copyTestResourcesTask = project.tasks.create("copyTest${variationName}Resources", Copy) + copyTestResourcesTask.from("${projectDir}/src/test/resources") + copyTestResourcesTask.into("${testClassesPath}/${variationPath}") + copyTestResourcesTask.execute() + } +} \ No newline at end of file diff --git a/storio-sqlite-annotations-processor-test/proguard-rules.pro b/storio-sqlite-annotations-processor-test/proguard-rules.pro new file mode 100644 index 000000000..955c8824d --- /dev/null +++ b/storio-sqlite-annotations-processor-test/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/ilyazorin/Development/Android/android-sdk-macosx/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml b/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml new file mode 100644 index 000000000..da125a1a5 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/storio-sqlite-annotations-processor-test/src/main/res/values/strings.xml b/storio-sqlite-annotations-processor-test/src/main/res/values/strings.xml new file mode 100644 index 000000000..91d6fbc11 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + StorIO SQLite annotations processor test + diff --git a/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java new file mode 100644 index 000000000..02a610e5b --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java @@ -0,0 +1,300 @@ +package com.pushtorefresh.storio.sqlite.annotations.processor.test; + +import com.google.testing.compile.JavaFileObjects; +import com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor; + +import org.junit.Test; + +import javax.tools.JavaFileObject; + +import static com.google.common.truth.Truth.assert_; +import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource; + +public class StorIOSQLiteAnnotationsProcessorTest { + + @Test + public void shouldNotCompileIfPrivateClassAnnotatedWithTypeAnnotation() { + JavaFileObject model = JavaFileObjects + .forResource("PrivateClass.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteType can not be applied to private class: ActualClass"); + } + + @Test + public void shouldNotCompileIfNotClassAnnotatedWithTypeAnnotations() { + JavaFileObject model = JavaFileObjects + .forResource("AnnotatedInterface.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteType can be applied only to classes not to AnnotatedInterface"); + } + + @Test + public void shouldNotCompileIfAnnotatedFieldNotInsideClass() { + JavaFileObject model = JavaFileObjects + .forResource("AnnotatedFieldNotInsideClass.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Please apply StorIOSQLiteColumn only to members of class (fields or methods)" + + " - not to members of AnnotatedFieldNotInsideClass"); + } + + @Test + public void shouldNotCompileIfAnnotatedFieldInsideNotAnnotatedClass() { + JavaFileObject model = JavaFileObjects + .forResource("AnnotatedFieldInsideNotAnnotatedClass.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Please annotate class AnnotatedFieldInsideNotAnnotatedClass with StorIOSQLiteType"); + } + + @Test + public void shouldNotCompileIfAnnotatedFieldIsPrivate() { + JavaFileObject model = JavaFileObjects + .forResource("PrivateField.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteColumn can not be applied to private field or method: id"); + } + + //TODO ok for final method + @Test + public void shouldNotCompileIfAnnotatedFieldIsFinal() { + JavaFileObject model = JavaFileObjects + .forResource("FinalField.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteColumn can not be applied to final field: id"); + } + + @Test + public void shouldNotCompileIfAnnotatedMethodHasParameters() { + JavaFileObject model = JavaFileObjects + .forResource("MethodWithParameters.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteColumn can not be applied to method with parameters: id"); + } + + @Test + public void shouldNotCompileIfCreatorNotInsideClass() { + JavaFileObject model = JavaFileObjects + .forResource("CreatorNotInsideClass.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Please apply StorIOSQLiteCreator to constructor or factory method of class - not to CreatorNotInsideClass"); + } + + @Test + public void shouldNotCompileIfCreatorInsideNotAnnotatedClass() { + JavaFileObject model = JavaFileObjects + .forResource("CreatorInsideNotAnnotatedClass.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Please annotate class CreatorInsideNotAnnotatedClass with StorIOSQLiteType"); + } + + @Test + public void shouldNotCompileIfCreatorIsPrivate() { + JavaFileObject model = JavaFileObjects + .forResource("PrivateCreator.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteCreator can not be applied to private methods or constructors: "); + } + + @Test + public void shouldNotCompileIfCreatorMethodIsNotStatic() { + JavaFileObject model = JavaFileObjects + .forResource("NonStaticCreatorMethod.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteCreator can not be applied to non-static methods: creator"); + } + + @Test + public void shouldNotCompileIfCreatorMethodReturnsDifferentType() { + JavaFileObject model = JavaFileObjects + .forResource("CreatorMethodWithDifferentReturnType.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteCreator can not be applied to method with return type different " + + "from CreatorMethodWithDifferentReturnType"); + } + + @Test + public void shouldNotCompileIfTableIsEmpty() { + JavaFileObject model = JavaFileObjects + .forResource("EmptyTable.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Table name of EmptyTable annotated with StorIOSQLiteType is empty"); + } + + @Test + public void shouldNotCompileIfThereIsAColumnWithSameName() { + JavaFileObject model = JavaFileObjects + .forResource("SameColumnName.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Column name already used in this class: id"); + } + + @Test + public void shouldNotCompileIfClassContainsBothAnnotatedFieldsAndMethods() { + JavaFileObject model = JavaFileObjects + .forResource("MixedFieldsAndMethods.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Can't apply StorIOSQLiteColumn annotation to both fields and methods in a same class: MixedFieldsAndMethods"); + } + + @Test + public void shouldNotCompileIfTypeIsUnsupported() { + JavaFileObject model = JavaFileObjects + .forResource("UnsupportedType.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Unsupported type of field or method for StorIOSQLiteColumn annotation," + + " if you need to serialize/deserialize field of that type -> please write your own resolver"); + } + + @Test + public void shouldNotCompileIfIgnoreNullIsUsedOnPrimitive() { + JavaFileObject model = JavaFileObjects + .forResource("IgnoreNullOnPrimitive.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("ignoreNull should not be used for primitive type: id"); + } + + @Test + public void shouldNotCompileIfColumnNameIsEmpty() { + JavaFileObject model = JavaFileObjects + .forResource("EmptyColumnName.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Column name is empty: id"); + } + + @Test + public void shouldNotCompileIfClassContainsMultipleCreators() { + JavaFileObject model = JavaFileObjects + .forResource("MultipleCreators.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Only one creator method or constructor is allowed: MultipleCreators"); + } + + @Test + public void shouldNotCompileIfClassIsEmpty() { + JavaFileObject model = JavaFileObjects + .forResource("EmptyClass.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Class marked with StorIOSQLiteType annotation should have at least one field or method marked with " + + "StorIOSQLiteColumn annotation: EmptyClass"); + } + + @Test + public void shouldNotCompileIfClassDoesNotHaveKey() { + JavaFileObject model = JavaFileObjects + .forResource("NoKey.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Class marked with StorIOSQLiteType annotation should have at least one KEY field or method marked with " + + "StorIOSQLiteColumn annotation: NoKey"); + } + + @Test + public void shouldNotCompileIfClassNeedsCreatorAndDoesNotHaveOne() { + JavaFileObject model = JavaFileObjects + .forResource("NoCreator.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Class marked with StorIOSQLiteType annotation needs factory method or constructor marked with " + + "StorIOSQLiteCreator annotation: NoCreator"); + } + + @Test + public void shouldNotCompileIfCreatorsNumberOfArgumentsDoNotMatchWithColumnsNumber() { + JavaFileObject model = JavaFileObjects + .forResource("CreatorWithWrongNumberOfArguments.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("Class marked with StorIOSQLiteType annotation needs factory method or constructor marked with " + + "StorIOSQLiteCreator annotation with the same amount of parameters as the number of columns: " + + "CreatorWithWrongNumberOfArguments"); + } + +} \ No newline at end of file diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldInsideNotAnnotatedClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldInsideNotAnnotatedClass.java new file mode 100644 index 000000000..e12755820 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldInsideNotAnnotatedClass.java @@ -0,0 +1,7 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +public class AnnotatedFieldInsideNotAnnotatedClass { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldNotInsideClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldNotInsideClass.java new file mode 100644 index 000000000..6bfc4dd8c --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedFieldNotInsideClass.java @@ -0,0 +1,7 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +public interface AnnotatedFieldNotInsideClass { + + @StorIOSQLiteColumn(name = "id", key = true) + long id(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedInterface.java b/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedInterface.java new file mode 100644 index 000000000..4e8f39fa1 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/AnnotatedInterface.java @@ -0,0 +1,6 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public interface AnnotatedInterface { + +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java new file mode 100644 index 000000000..837d20635 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java @@ -0,0 +1,7 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +public class CreatorInsideNotAnnotatedClass { + + @StorIOSQLiteCreator + CreatorInsideNotAnnotatedClass(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java new file mode 100644 index 000000000..b65780582 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class CreatorMethodWithDifferentReturnType { + + @StorIOSQLiteCreator + static int creator(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorNotInsideClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorNotInsideClass.java new file mode 100644 index 000000000..546fd0d49 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorNotInsideClass.java @@ -0,0 +1,7 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +public interface CreatorNotInsideClass { + + @StorIOSQLiteCreator + CreatorNotInsideClass id(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java new file mode 100644 index 000000000..30190f3b1 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java @@ -0,0 +1,11 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class CreatorWithWrongNumberOfArguments { + + @StorIOSQLiteColumn(name = "id", key = true) + long id(); + + @StorIOSQLiteCreator + static CreatorWithWrongNumberOfArguments creator(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/EmptyClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/EmptyClass.java new file mode 100644 index 000000000..ac2a428f7 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/EmptyClass.java @@ -0,0 +1,6 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class EmptyClass { + +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/EmptyColumnName.java b/storio-sqlite-annotations-processor-test/src/test/resources/EmptyColumnName.java new file mode 100644 index 000000000..6641c70f4 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/EmptyColumnName.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class EmptyColumnName { + + @StorIOSQLiteColumn(name = "", key = true) + long id; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/EmptyTable.java b/storio-sqlite-annotations-processor-test/src/test/resources/EmptyTable.java new file mode 100644 index 000000000..fa0631399 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/EmptyTable.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "") +public class EmptyTable { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/FinalField.java b/storio-sqlite-annotations-processor-test/src/test/resources/FinalField.java new file mode 100644 index 000000000..78e4bd1b7 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/FinalField.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class FinalField { + + @StorIOSQLiteColumn(name = "id", key = true) + final long id; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/IgnoreNullOnPrimitive.java b/storio-sqlite-annotations-processor-test/src/test/resources/IgnoreNullOnPrimitive.java new file mode 100644 index 000000000..788a26e6e --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/IgnoreNullOnPrimitive.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class IgnoreNullOnPrimitive { + + @StorIOSQLiteColumn(name = "id", key = true, ignoreNull = true) + long id; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java b/storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java new file mode 100644 index 000000000..5eeb11e70 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java @@ -0,0 +1,10 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class MethodWithParameters { + + @StorIOSQLiteColumn(name = "id", key = true) + long id(long id) { + + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java b/storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java new file mode 100644 index 000000000..c7cf1724a --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java @@ -0,0 +1,11 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class MixedFieldsAndMethods { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; + + @StorIOSQLiteColumn(name = "name") + String name(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java b/storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java new file mode 100644 index 000000000..337634ccc --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java @@ -0,0 +1,11 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class MultipleCreators { + + @StorIOSQLiteCreator + static MultipleCreators creator1(); + + @StorIOSQLiteCreator + static MultipleCreators creator2(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java b/storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java new file mode 100644 index 000000000..5b63a4909 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class NoCreator { + + @StorIOSQLiteColumn(name = "id", key = true) + long id(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/NoKey.java b/storio-sqlite-annotations-processor-test/src/test/resources/NoKey.java new file mode 100644 index 000000000..1fa3a168b --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/NoKey.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class NoKey { + + @StorIOSQLiteColumn(name = "id") + long id; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java new file mode 100644 index 000000000..db8ec3ea6 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class NonStaticCreatorMethod { + + @StorIOSQLiteCreator + NonStaticCreatorMethod creator(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrivateClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateClass.java new file mode 100644 index 000000000..9bb9f3ecb --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateClass.java @@ -0,0 +1,17 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +public class PrivateClass { + + @StorIOSQLiteType(table = "table") + private class ActualClass { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; + + @StorIOSQLiteColumn(name = "author") + String author; + + @StorIOSQLiteColumn(name = "content") + String content; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java new file mode 100644 index 000000000..85fd6433f --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class PrivateCreator { + + @StorIOSQLiteCreator + private PrivateCreator(); +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrivateField.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateField.java new file mode 100644 index 000000000..d481e3109 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateField.java @@ -0,0 +1,8 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class PrivateField { + + @StorIOSQLiteColumn(name = "id", key = true) + private long id; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/SameColumnName.java b/storio-sqlite-annotations-processor-test/src/test/resources/SameColumnName.java new file mode 100644 index 000000000..4c09bd2e3 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/SameColumnName.java @@ -0,0 +1,11 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class SameColumnName { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; + + @StorIOSQLiteColumn(name = "id") + String name; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/UnsupportedType.java b/storio-sqlite-annotations-processor-test/src/test/resources/UnsupportedType.java new file mode 100644 index 000000000..ba6552fa4 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/UnsupportedType.java @@ -0,0 +1,15 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class UnsupportedType { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; + + @StorIOSQLiteColumn(name = "class") + UnsupprtedClass unsupprtedClass; + + public class UnsupprtedClass { + + } +} diff --git a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/StorIOSQLiteProcessor.java b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/StorIOSQLiteProcessor.java index 293762865..ef2377001 100644 --- a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/StorIOSQLiteProcessor.java +++ b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/StorIOSQLiteProcessor.java @@ -73,10 +73,12 @@ protected StorIOSQLiteTypeMeta processAnnotatedClass(@NotNull TypeElement classE final String tableName = storIOSQLiteType.table(); - if (tableName == null || tableName.length() == 0) { - throw new ProcessingException( - classElement, - "Table name of " + classElement.getQualifiedName() + " annotated with " + StorIOSQLiteType.class.getSimpleName() + " is null or empty" + if (tableName.length() == 0) { + throw new ProcessingException(classElement, + "Table name of " + + classElement.getSimpleName() + + " annotated with " + StorIOSQLiteType.class.getSimpleName() + + " is empty" ); } @@ -93,7 +95,8 @@ protected StorIOSQLiteTypeMeta processAnnotatedClass(@NotNull TypeElement classE * @param annotatedClasses map of classes annotated with {@link StorIOSQLiteType} */ @Override - protected void processAnnotatedFieldsOrMethods(@NotNull final RoundEnvironment roundEnvironment, @NotNull Map annotatedClasses) { + protected void processAnnotatedFieldsOrMethods(@NotNull final RoundEnvironment roundEnvironment, + @NotNull Map annotatedClasses) { final Set elementsAnnotatedWithStorIOSQLiteColumn = roundEnvironment.getElementsAnnotatedWith(StorIOSQLiteColumn.class); @@ -105,26 +108,21 @@ protected void processAnnotatedFieldsOrMethods(@NotNull final RoundEnvironment r final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = annotatedClasses.get(storIOSQLiteColumnMeta.enclosingElement); - if (storIOSQLiteTypeMeta == null) { - throw new ProcessingException(annotatedFieldElement, "Field marked with " - + StorIOSQLiteColumn.class.getSimpleName() - + " annotation should be placed in class marked by " - + StorIOSQLiteType.class.getSimpleName() - + " annotation" - ); - } - // If class already contains column with same name -> throw an exception. if (storIOSQLiteTypeMeta.columns.containsKey(storIOSQLiteColumnMeta.storIOColumn.name())) { - throw new ProcessingException(annotatedFieldElement, "Column name already used in this class"); + throw new ProcessingException(annotatedFieldElement, + "Column name already used in this class: " + + storIOSQLiteColumnMeta.storIOColumn.name()); } // If field annotation applied to both fields and methods in a same class. if ((storIOSQLiteTypeMeta.needCreator && !storIOSQLiteColumnMeta.isMethod()) || (!storIOSQLiteTypeMeta.needCreator && storIOSQLiteColumnMeta.isMethod() && !storIOSQLiteTypeMeta.columns.isEmpty())) { - throw new ProcessingException(annotatedFieldElement, "Can't apply" - + StorIOSQLiteColumn.class.getSimpleName() - + " annotation to both fields and methods in a same class" + throw new ProcessingException(annotatedFieldElement, + "Can't apply " + + StorIOSQLiteColumn.class.getSimpleName() + + " annotation to both fields and methods in a same class: " + + storIOSQLiteTypeMeta.simpleName ); } @@ -153,28 +151,33 @@ protected StorIOSQLiteColumnMeta processAnnotatedFieldOrMethod(@NotNull final El final JavaType javaType; try { - javaType = JavaType.from(annotatedField.getKind() == ElementKind.FIELD ? annotatedField.asType() : ((ExecutableElement) annotatedField).getReturnType()); + javaType = JavaType.from(annotatedField.getKind() == ElementKind.FIELD + ? annotatedField.asType() + : ((ExecutableElement) annotatedField).getReturnType()); } catch (Exception e) { - throw new ProcessingException(annotatedField, "Unsupported type of field for " - + StorIOSQLiteColumn.class.getSimpleName() - + " annotation, if you need to serialize/deserialize field of that type " - + "-> please write your own resolver: " - + e.getMessage() + throw new ProcessingException(annotatedField, + "Unsupported type of field or method for " + + StorIOSQLiteColumn.class.getSimpleName() + + " annotation, if you need to serialize/deserialize field of that type " + + "-> please write your own resolver: " + + e.getMessage() ); } final StorIOSQLiteColumn storIOSQLiteColumn = annotatedField.getAnnotation(StorIOSQLiteColumn.class); if (storIOSQLiteColumn.ignoreNull() && annotatedField.asType().getKind().isPrimitive()) { - throw new ProcessingException( - annotatedField, - "ignoreNull should not be used for primitive type: " + annotatedField.asType()); + throw new ProcessingException(annotatedField, + "ignoreNull should not be used for primitive type: " + + annotatedField.getSimpleName()); } final String columnName = storIOSQLiteColumn.name(); - if (columnName == null || columnName.length() == 0) { - throw new ProcessingException(annotatedField, "Column name is null or empty"); + if (columnName.length() == 0) { + throw new ProcessingException(annotatedField, + "Column name is empty: " + + annotatedField.getSimpleName()); } return new StorIOSQLiteColumnMeta( @@ -193,7 +196,8 @@ protected StorIOSQLiteColumnMeta processAnnotatedFieldOrMethod(@NotNull final El * @param annotatedClasses map of classes annotated with {@link StorIOSQLiteType} */ @Override - protected void processAnnotatedExecutables(@NotNull RoundEnvironment roundEnvironment, @NotNull Map annotatedClasses) { + protected void processAnnotatedExecutables(@NotNull RoundEnvironment roundEnvironment, + @NotNull Map annotatedClasses) { final Set elementsAnnotatedWithStorIOSQLiteCreator = roundEnvironment.getElementsAnnotatedWith(StorIOSQLiteCreator.class); @@ -207,21 +211,14 @@ protected void processAnnotatedExecutables(@NotNull RoundEnvironment roundEnviro final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = annotatedClasses.get(storIOSQLiteCreatorMeta.enclosingElement); - if (storIOSQLiteTypeMeta == null) { - throw new ProcessingException(annotatedElement, "Method or constructor marked with " - + StorIOSQLiteCreator.class.getSimpleName() - + " annotation should be placed in class marked by " - + StorIOSQLiteType.class.getSimpleName() - + " annotation" - ); - } - // Put meta creator info. // If class already contains another creator -> throw exception. if (storIOSQLiteTypeMeta.creator == null) { storIOSQLiteTypeMeta.creator = annotatedExecutableElement; } else { - throw new ProcessingException(annotatedExecutableElement, "Only one creator method or constructor is allowed"); + throw new ProcessingException(annotatedExecutableElement, + "Only one creator method or constructor is allowed: " + + annotatedExecutableElement.getEnclosingElement().getSimpleName()); } } } @@ -236,9 +233,9 @@ protected void validateAnnotatedClassesAndColumns(@NotNull Map Date: Sat, 4 Feb 2017 18:34:10 +0200 Subject: [PATCH 02/11] Fix test cases related to methods in StorIOSQLiteAnnotationsProcessor --- .../StorIOSQLiteAnnotationsProcessorTest.java | 12 +++++++++++- .../CreatorInsideNotAnnotatedClass.java | 4 +++- .../CreatorMethodWithDifferentReturnType.java | 4 +++- .../CreatorWithWrongNumberOfArguments.java | 8 ++++++-- .../src/test/resources/FinalMethod.java | 17 +++++++++++++++++ .../test/resources/MethodWithParameters.java | 2 +- .../test/resources/MixedFieldsAndMethods.java | 4 +++- .../src/test/resources/MultipleCreators.java | 8 ++++++-- .../src/test/resources/NoCreator.java | 4 +++- .../test/resources/NonStaticCreatorMethod.java | 4 +++- .../src/test/resources/PrivateCreator.java | 4 +++- 11 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/FinalMethod.java diff --git a/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java index 02a610e5b..339754b93 100644 --- a/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java +++ b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java @@ -73,7 +73,6 @@ public void shouldNotCompileIfAnnotatedFieldIsPrivate() { .withErrorContaining("StorIOSQLiteColumn can not be applied to private field or method: id"); } - //TODO ok for final method @Test public void shouldNotCompileIfAnnotatedFieldIsFinal() { JavaFileObject model = JavaFileObjects @@ -86,6 +85,17 @@ public void shouldNotCompileIfAnnotatedFieldIsFinal() { .withErrorContaining("StorIOSQLiteColumn can not be applied to final field: id"); } + @Test + public void shouldCompileIfAnnotatedMethodIsFinal() { + JavaFileObject model = JavaFileObjects + .forResource("FinalMethod.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError(); + } + @Test public void shouldNotCompileIfAnnotatedMethodHasParameters() { JavaFileObject model = JavaFileObjects diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java index 837d20635..50253d1be 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorInsideNotAnnotatedClass.java @@ -3,5 +3,7 @@ public class CreatorInsideNotAnnotatedClass { @StorIOSQLiteCreator - CreatorInsideNotAnnotatedClass(); + CreatorInsideNotAnnotatedClass() { + + } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java index b65780582..0f49692f2 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorMethodWithDifferentReturnType.java @@ -4,5 +4,7 @@ public class CreatorMethodWithDifferentReturnType { @StorIOSQLiteCreator - static int creator(); + static int creator() { + return 0; + } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java index 30190f3b1..9c6d8a4ad 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/CreatorWithWrongNumberOfArguments.java @@ -4,8 +4,12 @@ public class CreatorWithWrongNumberOfArguments { @StorIOSQLiteColumn(name = "id", key = true) - long id(); + long id() { + return 0; + } @StorIOSQLiteCreator - static CreatorWithWrongNumberOfArguments creator(); + static CreatorWithWrongNumberOfArguments creator() { + return new CreatorWithWrongNumberOfArguments(); + } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/FinalMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/FinalMethod.java new file mode 100644 index 000000000..7d52d7866 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/FinalMethod.java @@ -0,0 +1,17 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class FinalMethod { + + private long id; + + @StorIOSQLiteColumn(name = "id", key = true) + final long id() { + return id; + } + + @StorIOSQLiteCreator + public FinalMethod(long id) { + this.id = id; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java b/storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java index 5eeb11e70..8528bb5fc 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/MethodWithParameters.java @@ -5,6 +5,6 @@ public class MethodWithParameters { @StorIOSQLiteColumn(name = "id", key = true) long id(long id) { - + return id; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java b/storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java index c7cf1724a..5084ee7c3 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/MixedFieldsAndMethods.java @@ -7,5 +7,7 @@ public class MixedFieldsAndMethods { long id; @StorIOSQLiteColumn(name = "name") - String name(); + String name() { + return "name"; + } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java b/storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java index 337634ccc..4b42a0f54 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/MultipleCreators.java @@ -4,8 +4,12 @@ public class MultipleCreators { @StorIOSQLiteCreator - static MultipleCreators creator1(); + static MultipleCreators creator1() { + return new MultipleCreators(); + } @StorIOSQLiteCreator - static MultipleCreators creator2(); + static MultipleCreators creator2() { + return new MultipleCreators(); + } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java b/storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java index 5b63a4909..ea3f62564 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/NoCreator.java @@ -4,5 +4,7 @@ public class NoCreator { @StorIOSQLiteColumn(name = "id", key = true) - long id(); + long id() { + return 0; + } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java index db8ec3ea6..db8e3efa0 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/NonStaticCreatorMethod.java @@ -4,5 +4,7 @@ public class NonStaticCreatorMethod { @StorIOSQLiteCreator - NonStaticCreatorMethod creator(); + NonStaticCreatorMethod creator() { + return new NonStaticCreatorMethod(); + } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java index 85fd6433f..e4a09d2db 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrivateCreator.java @@ -4,5 +4,7 @@ public class PrivateCreator { @StorIOSQLiteCreator - private PrivateCreator(); + private PrivateCreator() { + return new PrivateCreator(); + } } From 0f66d4f8b6e54a5d0980c7bb884a78ab4670e2f1 Mon Sep 17 00:00:00 2001 From: Ilya Zorin Date: Sun, 5 Feb 2017 17:59:13 +0200 Subject: [PATCH 03/11] Tests for regular cases in StorIOSQLiteAnnotationsProcessor --- .../processor/StorIOAnnotationsProcessor.java | 9 +- .../StorIOSQLiteAnnotationsProcessorTest.java | 252 ++++++++++++++---- .../resources/AbsenceOfNoArgConstructor.java | 12 + .../src/test/resources/BoxedTypesFields.java | 23 ++ .../resources/BoxedTypesFieldsIgnoreNull.java | 23 ++ ...ypesFieldsIgnoreNullSQLiteTypeMapping.java | 14 + ...sIgnoreNullStorIOSQLiteDeleteResolver.java | 24 ++ ...eldsIgnoreNullStorIOSQLiteGetResolver.java | 41 +++ ...eldsIgnoreNullStorIOSQLitePutResolver.java | 67 +++++ .../BoxedTypesFieldsSQLiteTypeMapping.java | 14 + ...TypesFieldsStorIOSQLiteDeleteResolver.java | 24 ++ ...xedTypesFieldsStorIOSQLiteGetResolver.java | 41 +++ ...xedTypesFieldsStorIOSQLitePutResolver.java | 55 ++++ .../BoxedTypesMethodFactoryMethod.java | 63 +++++ .../BoxedTypesMethodsConstructor.java | 58 ++++ ...oxedTypesMethodsConstructorIgnoreNull.java | 58 ++++ ...onstructorIgnoreNullSQLiteTypeMapping.java | 14 + ...rIgnoreNullStorIOSQLiteDeleteResolver.java | 24 ++ ...ctorIgnoreNullStorIOSQLiteGetResolver.java | 54 ++++ ...ctorIgnoreNullStorIOSQLitePutResolver.java | 67 +++++ ...esMethodsConstructorSQLiteTypeMapping.java | 14 + ...ConstructorStorIOSQLiteDeleteResolver.java | 24 ++ ...odsConstructorStorIOSQLiteGetResolver.java | 54 ++++ ...odsConstructorStorIOSQLitePutResolver.java | 55 ++++ .../BoxedTypesMethodsFactoryMethod.java | 63 +++++ ...edTypesMethodsFactoryMethodIgnoreNull.java | 64 +++++ ...toryMethodIgnoreNullSQLiteTypeMapping.java | 14 + ...dIgnoreNullStorIOSQLiteDeleteResolver.java | 24 ++ ...thodIgnoreNullStorIOSQLiteGetResolver.java | 54 ++++ ...thodIgnoreNullStorIOSQLitePutResolver.java | 67 +++++ ...MethodsFactoryMethodSQLiteTypeMapping.java | 14 + ...ctoryMethodStorIOSQLiteDeleteResolver.java | 24 ++ ...sFactoryMethodStorIOSQLiteGetResolver.java | 54 ++++ ...sFactoryMethodStorIOSQLitePutResolver.java | 55 ++++ .../{PrivateClass.java => InnerClass.java} | 4 +- .../src/test/resources/NestedClass.java | 17 ++ .../src/test/resources/PrimitiveFields.java | 29 ++ .../PrimitiveFieldsSQLiteTypeMapping.java | 14 + ...itiveFieldsStorIOSQLiteDeleteResolver.java | 24 ++ ...rimitiveFieldsStorIOSQLiteGetResolver.java | 31 +++ ...rimitiveFieldsStorIOSQLitePutResolver.java | 57 ++++ .../PrimitiveMethodsConstructor.java | 74 +++++ ...veMethodsConstructorSQLiteTypeMapping.java | 14 + ...ConstructorStorIOSQLiteDeleteResolver.java | 24 ++ ...odsConstructorStorIOSQLiteGetResolver.java | 33 +++ ...odsConstructorStorIOSQLitePutResolver.java | 57 ++++ .../PrimitiveMethodsFactoryMethod.java | 79 ++++++ ...MethodsFactoryMethodSQLiteTypeMapping.java | 14 + ...ctoryMethodStorIOSQLiteDeleteResolver.java | 24 ++ ...sFactoryMethodStorIOSQLiteGetResolver.java | 33 +++ ...sFactoryMethodStorIOSQLitePutResolver.java | 57 ++++ 51 files changed, 2048 insertions(+), 54 deletions(-) create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/AbsenceOfNoArgConstructor.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java rename storio-sqlite-annotations-processor-test/src/test/resources/{PrivateClass.java => InnerClass.java} (83%) create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/NestedClass.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java create mode 100644 storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java diff --git a/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java b/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java index fab299d24..4a97e08d4 100644 --- a/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java +++ b/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java @@ -29,6 +29,7 @@ import static javax.lang.model.element.ElementKind.CLASS; import static javax.lang.model.element.ElementKind.FIELD; import static javax.lang.model.element.ElementKind.METHOD; +import static javax.lang.model.element.ElementKind.PACKAGE; import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PRIVATE; import static javax.lang.model.element.Modifier.STATIC; @@ -87,18 +88,18 @@ private TypeElement validateAnnotatedClass(@NotNull final Element annotatedEleme // We expect here that annotatedElement is Class, annotation requires that via @Target. final TypeElement annotatedTypeElement = (TypeElement) annotatedElement; - if (annotatedTypeElement.getModifiers().contains(PRIVATE)) { + if (annotatedTypeElement.getKind() != CLASS) { throw new ProcessingException(annotatedElement, getTypeAnnotationClass().getSimpleName() - + " can not be applied to private class: " + + " can be applied only to classes not to " + annotatedTypeElement.getSimpleName() ); } - if (annotatedTypeElement.getKind() != CLASS) { + if (annotatedTypeElement.getEnclosingElement().getKind() != PACKAGE) { throw new ProcessingException(annotatedElement, getTypeAnnotationClass().getSimpleName() - + " can be applied only to classes not to " + + " can't be applied to nested or inner classes: " + annotatedTypeElement.getSimpleName() ); } diff --git a/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java index 339754b93..ec07d5822 100644 --- a/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java +++ b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java @@ -13,21 +13,30 @@ public class StorIOSQLiteAnnotationsProcessorTest { @Test - public void shouldNotCompileIfPrivateClassAnnotatedWithTypeAnnotation() { - JavaFileObject model = JavaFileObjects - .forResource("PrivateClass.java"); + public void shouldNotCompileIfNestedClassAnnotatedWithTypeAnnotation() { + JavaFileObject model = JavaFileObjects.forResource("NestedClass.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("StorIOSQLiteType can't be applied to nested or inner classes: ActualClass"); + } + + @Test + public void shouldNotCompileIfInnerClassAnnotatedWithTypeAnnotation() { + JavaFileObject model = JavaFileObjects.forResource("InnerClass.java"); assert_().about(javaSource()) .that(model) .processedWith(new StorIOSQLiteProcessor()) .failsToCompile() - .withErrorContaining("StorIOSQLiteType can not be applied to private class: ActualClass"); + .withErrorContaining("StorIOSQLiteType can't be applied to nested or inner classes: ActualClass"); } @Test public void shouldNotCompileIfNotClassAnnotatedWithTypeAnnotations() { - JavaFileObject model = JavaFileObjects - .forResource("AnnotatedInterface.java"); + JavaFileObject model = JavaFileObjects.forResource("AnnotatedInterface.java"); assert_().about(javaSource()) .that(model) @@ -38,8 +47,7 @@ public void shouldNotCompileIfNotClassAnnotatedWithTypeAnnotations() { @Test public void shouldNotCompileIfAnnotatedFieldNotInsideClass() { - JavaFileObject model = JavaFileObjects - .forResource("AnnotatedFieldNotInsideClass.java"); + JavaFileObject model = JavaFileObjects.forResource("AnnotatedFieldNotInsideClass.java"); assert_().about(javaSource()) .that(model) @@ -51,8 +59,7 @@ public void shouldNotCompileIfAnnotatedFieldNotInsideClass() { @Test public void shouldNotCompileIfAnnotatedFieldInsideNotAnnotatedClass() { - JavaFileObject model = JavaFileObjects - .forResource("AnnotatedFieldInsideNotAnnotatedClass.java"); + JavaFileObject model = JavaFileObjects.forResource("AnnotatedFieldInsideNotAnnotatedClass.java"); assert_().about(javaSource()) .that(model) @@ -63,8 +70,7 @@ public void shouldNotCompileIfAnnotatedFieldInsideNotAnnotatedClass() { @Test public void shouldNotCompileIfAnnotatedFieldIsPrivate() { - JavaFileObject model = JavaFileObjects - .forResource("PrivateField.java"); + JavaFileObject model = JavaFileObjects.forResource("PrivateField.java"); assert_().about(javaSource()) .that(model) @@ -75,8 +81,7 @@ public void shouldNotCompileIfAnnotatedFieldIsPrivate() { @Test public void shouldNotCompileIfAnnotatedFieldIsFinal() { - JavaFileObject model = JavaFileObjects - .forResource("FinalField.java"); + JavaFileObject model = JavaFileObjects.forResource("FinalField.java"); assert_().about(javaSource()) .that(model) @@ -87,8 +92,7 @@ public void shouldNotCompileIfAnnotatedFieldIsFinal() { @Test public void shouldCompileIfAnnotatedMethodIsFinal() { - JavaFileObject model = JavaFileObjects - .forResource("FinalMethod.java"); + JavaFileObject model = JavaFileObjects.forResource("FinalMethod.java"); assert_().about(javaSource()) .that(model) @@ -98,8 +102,7 @@ public void shouldCompileIfAnnotatedMethodIsFinal() { @Test public void shouldNotCompileIfAnnotatedMethodHasParameters() { - JavaFileObject model = JavaFileObjects - .forResource("MethodWithParameters.java"); + JavaFileObject model = JavaFileObjects.forResource("MethodWithParameters.java"); assert_().about(javaSource()) .that(model) @@ -110,8 +113,7 @@ public void shouldNotCompileIfAnnotatedMethodHasParameters() { @Test public void shouldNotCompileIfCreatorNotInsideClass() { - JavaFileObject model = JavaFileObjects - .forResource("CreatorNotInsideClass.java"); + JavaFileObject model = JavaFileObjects.forResource("CreatorNotInsideClass.java"); assert_().about(javaSource()) .that(model) @@ -122,8 +124,7 @@ public void shouldNotCompileIfCreatorNotInsideClass() { @Test public void shouldNotCompileIfCreatorInsideNotAnnotatedClass() { - JavaFileObject model = JavaFileObjects - .forResource("CreatorInsideNotAnnotatedClass.java"); + JavaFileObject model = JavaFileObjects.forResource("CreatorInsideNotAnnotatedClass.java"); assert_().about(javaSource()) .that(model) @@ -134,8 +135,7 @@ public void shouldNotCompileIfCreatorInsideNotAnnotatedClass() { @Test public void shouldNotCompileIfCreatorIsPrivate() { - JavaFileObject model = JavaFileObjects - .forResource("PrivateCreator.java"); + JavaFileObject model = JavaFileObjects.forResource("PrivateCreator.java"); assert_().about(javaSource()) .that(model) @@ -146,8 +146,7 @@ public void shouldNotCompileIfCreatorIsPrivate() { @Test public void shouldNotCompileIfCreatorMethodIsNotStatic() { - JavaFileObject model = JavaFileObjects - .forResource("NonStaticCreatorMethod.java"); + JavaFileObject model = JavaFileObjects.forResource("NonStaticCreatorMethod.java"); assert_().about(javaSource()) .that(model) @@ -158,8 +157,7 @@ public void shouldNotCompileIfCreatorMethodIsNotStatic() { @Test public void shouldNotCompileIfCreatorMethodReturnsDifferentType() { - JavaFileObject model = JavaFileObjects - .forResource("CreatorMethodWithDifferentReturnType.java"); + JavaFileObject model = JavaFileObjects.forResource("CreatorMethodWithDifferentReturnType.java"); assert_().about(javaSource()) .that(model) @@ -171,8 +169,7 @@ public void shouldNotCompileIfCreatorMethodReturnsDifferentType() { @Test public void shouldNotCompileIfTableIsEmpty() { - JavaFileObject model = JavaFileObjects - .forResource("EmptyTable.java"); + JavaFileObject model = JavaFileObjects.forResource("EmptyTable.java"); assert_().about(javaSource()) .that(model) @@ -183,8 +180,7 @@ public void shouldNotCompileIfTableIsEmpty() { @Test public void shouldNotCompileIfThereIsAColumnWithSameName() { - JavaFileObject model = JavaFileObjects - .forResource("SameColumnName.java"); + JavaFileObject model = JavaFileObjects.forResource("SameColumnName.java"); assert_().about(javaSource()) .that(model) @@ -195,8 +191,7 @@ public void shouldNotCompileIfThereIsAColumnWithSameName() { @Test public void shouldNotCompileIfClassContainsBothAnnotatedFieldsAndMethods() { - JavaFileObject model = JavaFileObjects - .forResource("MixedFieldsAndMethods.java"); + JavaFileObject model = JavaFileObjects.forResource("MixedFieldsAndMethods.java"); assert_().about(javaSource()) .that(model) @@ -220,8 +215,7 @@ public void shouldNotCompileIfTypeIsUnsupported() { @Test public void shouldNotCompileIfIgnoreNullIsUsedOnPrimitive() { - JavaFileObject model = JavaFileObjects - .forResource("IgnoreNullOnPrimitive.java"); + JavaFileObject model = JavaFileObjects.forResource("IgnoreNullOnPrimitive.java"); assert_().about(javaSource()) .that(model) @@ -232,8 +226,7 @@ public void shouldNotCompileIfIgnoreNullIsUsedOnPrimitive() { @Test public void shouldNotCompileIfColumnNameIsEmpty() { - JavaFileObject model = JavaFileObjects - .forResource("EmptyColumnName.java"); + JavaFileObject model = JavaFileObjects.forResource("EmptyColumnName.java"); assert_().about(javaSource()) .that(model) @@ -244,8 +237,7 @@ public void shouldNotCompileIfColumnNameIsEmpty() { @Test public void shouldNotCompileIfClassContainsMultipleCreators() { - JavaFileObject model = JavaFileObjects - .forResource("MultipleCreators.java"); + JavaFileObject model = JavaFileObjects.forResource("MultipleCreators.java"); assert_().about(javaSource()) .that(model) @@ -256,8 +248,7 @@ public void shouldNotCompileIfClassContainsMultipleCreators() { @Test public void shouldNotCompileIfClassIsEmpty() { - JavaFileObject model = JavaFileObjects - .forResource("EmptyClass.java"); + JavaFileObject model = JavaFileObjects.forResource("EmptyClass.java"); assert_().about(javaSource()) .that(model) @@ -269,8 +260,7 @@ public void shouldNotCompileIfClassIsEmpty() { @Test public void shouldNotCompileIfClassDoesNotHaveKey() { - JavaFileObject model = JavaFileObjects - .forResource("NoKey.java"); + JavaFileObject model = JavaFileObjects.forResource("NoKey.java"); assert_().about(javaSource()) .that(model) @@ -282,8 +272,7 @@ public void shouldNotCompileIfClassDoesNotHaveKey() { @Test public void shouldNotCompileIfClassNeedsCreatorAndDoesNotHaveOne() { - JavaFileObject model = JavaFileObjects - .forResource("NoCreator.java"); + JavaFileObject model = JavaFileObjects.forResource("NoCreator.java"); assert_().about(javaSource()) .that(model) @@ -295,8 +284,7 @@ public void shouldNotCompileIfClassNeedsCreatorAndDoesNotHaveOne() { @Test public void shouldNotCompileIfCreatorsNumberOfArgumentsDoNotMatchWithColumnsNumber() { - JavaFileObject model = JavaFileObjects - .forResource("CreatorWithWrongNumberOfArguments.java"); + JavaFileObject model = JavaFileObjects.forResource("CreatorWithWrongNumberOfArguments.java"); assert_().about(javaSource()) .that(model) @@ -307,4 +295,172 @@ public void shouldNotCompileIfCreatorsNumberOfArgumentsDoNotMatchWithColumnsNumb "CreatorWithWrongNumberOfArguments"); } + @Test + public void shouldNotCompileIfNoArgConstructorIsAbsent() { + JavaFileObject model = JavaFileObjects.forResource("AbsenceOfNoArgConstructor.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .failsToCompile() + .withErrorContaining("constructor AbsenceOfNoArgConstructor in class " + + "com.pushtorefresh.storio.sqlite.annotations.AbsenceOfNoArgConstructor cannot be applied to given types;\n" + + " required: long\n" + + " found: no arguments\n" + + " reason: actual and formal argument lists differ in length"); + } + + @Test + public void shouldCompileWithPrimitiveFields() { + JavaFileObject model = JavaFileObjects.forResource("PrimitiveFields.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("PrimitiveFieldsSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("PrimitiveFieldsStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("PrimitiveFieldsStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("PrimitiveFieldsStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithBoxedTypesFields() { + JavaFileObject model = JavaFileObjects.forResource("BoxedTypesFields.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesFieldsSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesFieldsStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesFieldsStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesFieldsStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithBoxedTypesFieldsMarkedAsIgnoreNull() { + JavaFileObject model = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNull.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithMethodsReturningPrimitivesAndConstructorAsCreator() { + JavaFileObject model = JavaFileObjects.forResource("PrimitiveMethodsConstructor.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("PrimitiveMethodsConstructorSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("PrimitiveMethodsConstructorStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithMethodsReturningBoxedTypesAndConstructorAsCreator() { + JavaFileObject model = JavaFileObjects.forResource("BoxedTypesMethodsConstructor.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesMethodsConstructorSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithMethodsReturningBoxedTypesAndMarkedAsIgnoreNullAndConstructorAsCreator() { + JavaFileObject model = JavaFileObjects.forResource("BoxedTypesMethodsConstructorIgnoreNull.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithMethodsReturningPrimitivesAndFactoryMethodAsCreator() { + JavaFileObject model = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethod.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithMethodsReturningBoxedTypesAndFactoryMethodAsCreator() { + JavaFileObject model = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethod.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + + @Test + public void shouldCompileWithMethodsReturningBoxedTypesAndMarkedAsIgnoreNullAndFactoryMethodAsCreator() { + JavaFileObject model = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodIgnoreNull.java"); + + JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java"); + JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java"); + JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java"); + JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java"); + + assert_().about(javaSource()) + .that(model) + .processedWith(new StorIOSQLiteProcessor()) + .compilesWithoutError() + .and() + .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); + } + } \ No newline at end of file diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/AbsenceOfNoArgConstructor.java b/storio-sqlite-annotations-processor-test/src/test/resources/AbsenceOfNoArgConstructor.java new file mode 100644 index 000000000..eb47a35e0 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/AbsenceOfNoArgConstructor.java @@ -0,0 +1,12 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class AbsenceOfNoArgConstructor { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; + + public AbsenceOfNoArgConstructor(long id) { + this.id = id; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java new file mode 100644 index 000000000..9c87a1369 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java @@ -0,0 +1,23 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class BoxedTypesFields { + + @StorIOSQLiteColumn(name = "booleanField") + Boolean booleanField; + + @StorIOSQLiteColumn(name = "shortField") + Short shortField; + + @StorIOSQLiteColumn(name = "intField") + Integer intField; + + @StorIOSQLiteColumn(name = "longField", key = true) + Long longField; + + @StorIOSQLiteColumn(name = "floatField") + Float floatField; + + @StorIOSQLiteColumn(name = "doubleField") + Double doubleField; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java new file mode 100644 index 000000000..b7c3acc85 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java @@ -0,0 +1,23 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class BoxedTypesFieldsIgnoreNull { + + @StorIOSQLiteColumn(name = "booleanField", ignoreNull = true) + Boolean booleanField; + + @StorIOSQLiteColumn(name = "shortField", ignoreNull = true) + Short shortField; + + @StorIOSQLiteColumn(name = "intField", ignoreNull = true) + Integer intField; + + @StorIOSQLiteColumn(name = "longField", key = true, ignoreNull = true) + Long longField; + + @StorIOSQLiteColumn(name = "floatField", ignoreNull = true) + Float floatField; + + @StorIOSQLiteColumn(name = "doubleField", ignoreNull = true) + Double doubleField; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java new file mode 100644 index 000000000..a553f3c84 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class BoxedTypesFieldsIgnoreNullSQLiteTypeMapping extends SQLiteTypeMapping { + public BoxedTypesFieldsIgnoreNullSQLiteTypeMapping() { + super(new BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver(), + new BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver(), + new BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..a4b1d6778 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesFieldsIgnoreNull object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.longField) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..02ccf9554 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java @@ -0,0 +1,41 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; + +/** + * Generated resolver for Get Operation + */ +public class BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public BoxedTypesFieldsIgnoreNull mapFromCursor(@NonNull Cursor cursor) { + BoxedTypesFieldsIgnoreNull object = new BoxedTypesFieldsIgnoreNull(); + + if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { + object.floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + } + if (!cursor.isNull(cursor.getColumnIndex("longField"))) { + object.longField = cursor.getLong(cursor.getColumnIndex("longField")); + } + if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { + object.doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + } + if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { + object.booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + } + if (!cursor.isNull(cursor.getColumnIndex("intField"))) { + object.intField = cursor.getInt(cursor.getColumnIndex("intField")); + } + if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { + object.shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + } + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java new file mode 100644 index 000000000..4cf26a560 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java @@ -0,0 +1,67 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull BoxedTypesFieldsIgnoreNull object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesFieldsIgnoreNull object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.longField) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull BoxedTypesFieldsIgnoreNull object) { + ContentValues contentValues = new ContentValues(6); + + if (object.floatField != null) { + contentValues.put("floatField", object.floatField); + } + if (object.longField != null) { + contentValues.put("longField", object.longField); + } + if (object.doubleField != null) { + contentValues.put("doubleField", object.doubleField); + } + if (object.booleanField != null) { + contentValues.put("booleanField", object.booleanField); + } + if (object.intField != null) { + contentValues.put("intField", object.intField); + } + if (object.shortField != null) { + contentValues.put("shortField", object.shortField); + } + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java new file mode 100644 index 000000000..1519786b5 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class BoxedTypesFieldsSQLiteTypeMapping extends SQLiteTypeMapping { + public BoxedTypesFieldsSQLiteTypeMapping() { + super(new BoxedTypesFieldsStorIOSQLitePutResolver(), + new BoxedTypesFieldsStorIOSQLiteGetResolver(), + new BoxedTypesFieldsStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..b2be3f3dc --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class BoxedTypesFieldsStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesFields object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.longField) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..786bfae4e --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java @@ -0,0 +1,41 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; + +/** + * Generated resolver for Get Operation + */ +public class BoxedTypesFieldsStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public BoxedTypesFields mapFromCursor(@NonNull Cursor cursor) { + BoxedTypesFields object = new BoxedTypesFields(); + + if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { + object.floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + } + if (!cursor.isNull(cursor.getColumnIndex("longField"))) { + object.longField = cursor.getLong(cursor.getColumnIndex("longField")); + } + if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { + object.doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + } + if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { + object.booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + } + if (!cursor.isNull(cursor.getColumnIndex("intField"))) { + object.intField = cursor.getInt(cursor.getColumnIndex("intField")); + } + if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { + object.shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + } + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java new file mode 100644 index 000000000..20a1897ed --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java @@ -0,0 +1,55 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class BoxedTypesFieldsStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull BoxedTypesFields object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesFields object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.longField) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull BoxedTypesFields object) { + ContentValues contentValues = new ContentValues(6); + + contentValues.put("floatField", object.floatField); + contentValues.put("longField", object.longField); + contentValues.put("doubleField", object.doubleField); + contentValues.put("booleanField", object.booleanField); + contentValues.put("intField", object.intField); + contentValues.put("shortField", object.shortField); + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java new file mode 100644 index 000000000..0fdd7a4ab --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java @@ -0,0 +1,63 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class BoxedTypesMethodsFactoryMethod { + + private Boolean booleanField; + + private Short shortField; + + private Integer intField; + + private Long longField; + + private Float floatField; + + private Double doubleField; + + @StorIOSQLiteCreator + public static BoxedTypesMethodsFactoryMethod create(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, + Double doubleField) { + return new BoxedTypesMethodsFactoryMethod(booleanField, shortField, intField, longField, floatField, doubleField); + } + + private BoxedTypesMethodsFactoryMethod(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, + Double doubleField) { + this.booleanField = booleanField; + this.shortField = shortField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + } + + @StorIOSQLiteColumn(name = "booleanField") + public Boolean isBooleanField() { + return booleanField; + } + + @StorIOSQLiteColumn(name = "shortField") + public Short getShortField() { + return shortField; + } + + @StorIOSQLiteColumn(name = "intField") + public Integer getIntField() { + return intField; + } + + @StorIOSQLiteColumn(name = "longField", key = true) + public Long getLongField() { + return longField; + } + + @StorIOSQLiteColumn(name = "floatField") + public Float getFloatField() { + return floatField; + } + + @StorIOSQLiteColumn(name = "doubleField") + public Double getDoubleField() { + return doubleField; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java new file mode 100644 index 000000000..8259cb8d9 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java @@ -0,0 +1,58 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class BoxedTypesMethodsConstructor { + + private Boolean booleanField; + + private Short shortField; + + private Integer intField; + + private Long longField; + + private Float floatField; + + private Double doubleField; + + @StorIOSQLiteCreator + public BoxedTypesMethodsConstructor(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, + Double doubleField) { + this.booleanField = booleanField; + this.shortField = shortField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + } + + @StorIOSQLiteColumn(name = "booleanField") + public Boolean isBooleanField() { + return booleanField; + } + + @StorIOSQLiteColumn(name = "shortField") + public Short getShortField() { + return shortField; + } + + @StorIOSQLiteColumn(name = "intField") + public Integer getIntField() { + return intField; + } + + @StorIOSQLiteColumn(name = "longField", key = true) + public Long getLongField() { + return longField; + } + + @StorIOSQLiteColumn(name = "floatField") + public Float getFloatField() { + return floatField; + } + + @StorIOSQLiteColumn(name = "doubleField") + public Double getDoubleField() { + return doubleField; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java new file mode 100644 index 000000000..ccd18d21f --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java @@ -0,0 +1,58 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class BoxedTypesMethodsConstructorIgnoreNull { + + private Boolean booleanField; + + private Short shortField; + + private Integer intField; + + private Long longField; + + private Float floatField; + + private Double doubleField; + + @StorIOSQLiteCreator + public BoxedTypesMethodsConstructorIgnoreNull(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, + Double doubleField) { + this.booleanField = booleanField; + this.shortField = shortField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + } + + @StorIOSQLiteColumn(name = "booleanField", ignoreNull = true) + public Boolean isBooleanField() { + return booleanField; + } + + @StorIOSQLiteColumn(name = "shortField", ignoreNull = true) + public Short getShortField() { + return shortField; + } + + @StorIOSQLiteColumn(name = "intField", ignoreNull = true) + public Integer getIntField() { + return intField; + } + + @StorIOSQLiteColumn(name = "longField", key = true, ignoreNull = true) + public Long getLongField() { + return longField; + } + + @StorIOSQLiteColumn(name = "floatField", ignoreNull = true) + public Float getFloatField() { + return floatField; + } + + @StorIOSQLiteColumn(name = "doubleField", ignoreNull = true) + public Double getDoubleField() { + return doubleField; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java new file mode 100644 index 000000000..f68559a34 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping extends SQLiteTypeMapping { + public BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping() { + super(new BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver(), + new BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver(), + new BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..e6056cd05 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsConstructorIgnoreNull object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..e09039295 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java @@ -0,0 +1,54 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; + +/** + * Generated resolver for Get Operation + */ +public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public BoxedTypesMethodsConstructorIgnoreNull mapFromCursor(@NonNull Cursor cursor) { + + Boolean booleanField = null; + if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { + booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + } + Short shortField = null; + if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { + shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + } + Integer intField = null; + if (!cursor.isNull(cursor.getColumnIndex("intField"))) { + intField = cursor.getInt(cursor.getColumnIndex("intField")); + } + Long longField = null; + if (!cursor.isNull(cursor.getColumnIndex("longField"))) { + longField = cursor.getLong(cursor.getColumnIndex("longField")); + } + Float floatField = null; + if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { + floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + } + Double doubleField = null; + if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { + doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + } + + BoxedTypesMethodsConstructorIgnoreNull object = new BoxedTypesMethodsConstructorIgnoreNull(booleanField, shortField, intField, longField, floatField, doubleField); + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java new file mode 100644 index 000000000..a47c4eb6e --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java @@ -0,0 +1,67 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsConstructorIgnoreNull object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsConstructorIgnoreNull object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsConstructorIgnoreNull object) { + ContentValues contentValues = new ContentValues(6); + + if (object.getFloatField() != null) { + contentValues.put("floatField", object.getFloatField()); + } + if (object.getLongField() != null) { + contentValues.put("longField", object.getLongField()); + } + if (object.getDoubleField() != null) { + contentValues.put("doubleField", object.getDoubleField()); + } + if (object.isBooleanField() != null) { + contentValues.put("booleanField", object.isBooleanField()); + } + if (object.getIntField() != null) { + contentValues.put("intField", object.getIntField()); + } + if (object.getShortField() != null) { + contentValues.put("shortField", object.getShortField()); + } + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java new file mode 100644 index 000000000..4b5e370be --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class BoxedTypesMethodsConstructorSQLiteTypeMapping extends SQLiteTypeMapping { + public BoxedTypesMethodsConstructorSQLiteTypeMapping() { + super(new BoxedTypesMethodsConstructorStorIOSQLitePutResolver(), + new BoxedTypesMethodsConstructorStorIOSQLiteGetResolver(), + new BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..1f84d4b08 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsConstructor object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..d638045fe --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java @@ -0,0 +1,54 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; + +/** + * Generated resolver for Get Operation + */ +public class BoxedTypesMethodsConstructorStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public BoxedTypesMethodsConstructor mapFromCursor(@NonNull Cursor cursor) { + + Boolean booleanField = null; + if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { + booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + } + Short shortField = null; + if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { + shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + } + Integer intField = null; + if (!cursor.isNull(cursor.getColumnIndex("intField"))) { + intField = cursor.getInt(cursor.getColumnIndex("intField")); + } + Long longField = null; + if (!cursor.isNull(cursor.getColumnIndex("longField"))) { + longField = cursor.getLong(cursor.getColumnIndex("longField")); + } + Float floatField = null; + if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { + floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + } + Double doubleField = null; + if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { + doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + } + + BoxedTypesMethodsConstructor object = new BoxedTypesMethodsConstructor(booleanField, shortField, intField, longField, floatField, doubleField); + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java new file mode 100644 index 000000000..5b42048c1 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java @@ -0,0 +1,55 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class BoxedTypesMethodsConstructorStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsConstructor object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsConstructor object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsConstructor object) { + ContentValues contentValues = new ContentValues(6); + + contentValues.put("floatField", object.getFloatField()); + contentValues.put("longField", object.getLongField()); + contentValues.put("doubleField", object.getDoubleField()); + contentValues.put("booleanField", object.isBooleanField()); + contentValues.put("intField", object.getIntField()); + contentValues.put("shortField", object.getShortField()); + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java new file mode 100644 index 000000000..e06fa5628 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java @@ -0,0 +1,63 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class BoxedTypesMethodsFactoryMethod { + + private Boolean booleanField; + + private Short shortField; + + private Integer intField; + + private Long longField; + + private Float floatField; + + private Double doubleField; + + @StorIOSQLiteCreator + public static BoxedTypesMethodsFactoryMethod create(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, + Double doubleField) { + return new BoxedTypesMethodsFactoryMethod(booleanField, shortField, intField, longField, floatField, doubleField); + } + + private BoxedTypesMethodsFactoryMethod(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, + Double doubleField) { + this.booleanField = booleanField; + this.shortField = shortField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + } + + @StorIOSQLiteColumn(name = "booleanField") + public Boolean isBooleanField() { + return booleanField; + } + + @StorIOSQLiteColumn(name = "shortField") + public Short getShortField() { + return shortField; + } + + @StorIOSQLiteColumn(name = "intField") + public Integer getIntField() { + return intField; + } + + @StorIOSQLiteColumn(name = "longField", key = true) + public Long getLongField() { + return longField; + } + + @StorIOSQLiteColumn(name = "floatField") + public Float getFloatField() { + return floatField; + } + + @StorIOSQLiteColumn(name = "doubleField") + public Double getDoubleField() { + return doubleField; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java new file mode 100644 index 000000000..79dc8b150 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java @@ -0,0 +1,64 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class BoxedTypesMethodsFactoryMethodIgnoreNull { + + private Boolean booleanField; + + private Short shortField; + + private Integer intField; + + private Long longField; + + private Float floatField; + + private Double doubleField; + + @StorIOSQLiteCreator + public static BoxedTypesMethodsFactoryMethodIgnoreNull create(Boolean booleanField, Short shortField, Integer intField, Long longField, + Float floatField, Double doubleField) { + return new BoxedTypesMethodsFactoryMethodIgnoreNull(booleanField, shortField, intField, longField, floatField, doubleField); + } + + private BoxedTypesMethodsFactoryMethodIgnoreNull(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, + Double doubleField) { + this.booleanField = booleanField; + this.shortField = shortField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + } + + @StorIOSQLiteColumn(name = "booleanField", ignoreNull = true) + public Boolean isBooleanField() { + return booleanField; + } + + @StorIOSQLiteColumn(name = "shortField", ignoreNull = true) + public Short getShortField() { + return shortField; + } + + @StorIOSQLiteColumn(name = "intField", ignoreNull = true) + public Integer getIntField() { + return intField; + } + + @StorIOSQLiteColumn(name = "longField", key = true, ignoreNull = true) + public Long getLongField() { + return longField; + } + + @StorIOSQLiteColumn(name = "floatField", ignoreNull = true) + public Float getFloatField() { + return floatField; + } + + @StorIOSQLiteColumn(name = "doubleField", ignoreNull = true) + public Double getDoubleField() { + return doubleField; + } +} + diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java new file mode 100644 index 000000000..1ef21975d --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping extends SQLiteTypeMapping { + public BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping() { + super(new BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver(), + new BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver(), + new BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..e981180e6 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsFactoryMethodIgnoreNull object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..f6db8ed76 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java @@ -0,0 +1,54 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; + +/** + * Generated resolver for Get Operation + */ +public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public BoxedTypesMethodsFactoryMethodIgnoreNull mapFromCursor(@NonNull Cursor cursor) { + + Boolean booleanField = null; + if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { + booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + } + Short shortField = null; + if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { + shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + } + Integer intField = null; + if (!cursor.isNull(cursor.getColumnIndex("intField"))) { + intField = cursor.getInt(cursor.getColumnIndex("intField")); + } + Long longField = null; + if (!cursor.isNull(cursor.getColumnIndex("longField"))) { + longField = cursor.getLong(cursor.getColumnIndex("longField")); + } + Float floatField = null; + if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { + floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + } + Double doubleField = null; + if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { + doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + } + + BoxedTypesMethodsFactoryMethodIgnoreNull object = BoxedTypesMethodsFactoryMethodIgnoreNull.create(booleanField, shortField, intField, longField, floatField, doubleField); + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java new file mode 100644 index 000000000..dcd94ebb8 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java @@ -0,0 +1,67 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsFactoryMethodIgnoreNull object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsFactoryMethodIgnoreNull object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsFactoryMethodIgnoreNull object) { + ContentValues contentValues = new ContentValues(6); + + if (object.getFloatField() != null) { + contentValues.put("floatField", object.getFloatField()); + } + if (object.getLongField() != null) { + contentValues.put("longField", object.getLongField()); + } + if (object.getDoubleField() != null) { + contentValues.put("doubleField", object.getDoubleField()); + } + if (object.isBooleanField() != null) { + contentValues.put("booleanField", object.isBooleanField()); + } + if (object.getIntField() != null) { + contentValues.put("intField", object.getIntField()); + } + if (object.getShortField() != null) { + contentValues.put("shortField", object.getShortField()); + } + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java new file mode 100644 index 000000000..6b3fe054a --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class BoxedTypesMethodsFactoryMethodSQLiteTypeMapping extends SQLiteTypeMapping { + public BoxedTypesMethodsFactoryMethodSQLiteTypeMapping() { + super(new BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver(), + new BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver(), + new BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..f567b4e87 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsFactoryMethod object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..509594132 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -0,0 +1,54 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; + +/** + * Generated resolver for Get Operation + */ +public class BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public BoxedTypesMethodsFactoryMethod mapFromCursor(@NonNull Cursor cursor) { + + Boolean booleanField = null; + if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { + booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + } + Short shortField = null; + if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { + shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + } + Integer intField = null; + if (!cursor.isNull(cursor.getColumnIndex("intField"))) { + intField = cursor.getInt(cursor.getColumnIndex("intField")); + } + Long longField = null; + if (!cursor.isNull(cursor.getColumnIndex("longField"))) { + longField = cursor.getLong(cursor.getColumnIndex("longField")); + } + Float floatField = null; + if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { + floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + } + Double doubleField = null; + if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { + doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + } + + BoxedTypesMethodsFactoryMethod object = BoxedTypesMethodsFactoryMethod.create(booleanField, shortField, intField, longField, floatField, doubleField); + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java new file mode 100644 index 000000000..ff08af1e6 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -0,0 +1,55 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsFactoryMethod object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsFactoryMethod object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsFactoryMethod object) { + ContentValues contentValues = new ContentValues(6); + + contentValues.put("floatField", object.getFloatField()); + contentValues.put("longField", object.getLongField()); + contentValues.put("doubleField", object.getDoubleField()); + contentValues.put("booleanField", object.isBooleanField()); + contentValues.put("intField", object.getIntField()); + contentValues.put("shortField", object.getShortField()); + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrivateClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/InnerClass.java similarity index 83% rename from storio-sqlite-annotations-processor-test/src/test/resources/PrivateClass.java rename to storio-sqlite-annotations-processor-test/src/test/resources/InnerClass.java index 9bb9f3ecb..dc45e5e74 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrivateClass.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/InnerClass.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; -public class PrivateClass { +public class InnerClass { @StorIOSQLiteType(table = "table") - private class ActualClass { + public class ActualClass { @StorIOSQLiteColumn(name = "id", key = true) long id; diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/NestedClass.java b/storio-sqlite-annotations-processor-test/src/test/resources/NestedClass.java new file mode 100644 index 000000000..3aea11f0a --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/NestedClass.java @@ -0,0 +1,17 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +public class NestedClass { + + @StorIOSQLiteType(table = "table") + public static class ActualClass { + + @StorIOSQLiteColumn(name = "id", key = true) + long id; + + @StorIOSQLiteColumn(name = "author") + String author; + + @StorIOSQLiteColumn(name = "content") + String content; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java new file mode 100644 index 000000000..3d524bd4d --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java @@ -0,0 +1,29 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class PrimitiveFields { + + @StorIOSQLiteColumn(name = "booleanField") + boolean booleanField; + + @StorIOSQLiteColumn(name = "shortField") + short shortField; + + @StorIOSQLiteColumn(name = "intField") + int intField; + + @StorIOSQLiteColumn(name = "longField", key = true) + long longField; + + @StorIOSQLiteColumn(name = "floatField") + float floatField; + + @StorIOSQLiteColumn(name = "doubleField") + double doubleField; + + @StorIOSQLiteColumn(name = "stringField") + String stringField; + + @StorIOSQLiteColumn(name = "byteArrayField") + byte[] byteArrayField; +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java new file mode 100644 index 000000000..9d3b9c014 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class PrimitiveFieldsSQLiteTypeMapping extends SQLiteTypeMapping { + public PrimitiveFieldsSQLiteTypeMapping() { + super(new PrimitiveFieldsStorIOSQLitePutResolver(), + new PrimitiveFieldsStorIOSQLiteGetResolver(), + new PrimitiveFieldsStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..25ecdcc86 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class PrimitiveFieldsStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull PrimitiveFields object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.longField) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..5a4c0ef7a --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java @@ -0,0 +1,31 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; + +/** + * Generated resolver for Get Operation + */ +public class PrimitiveFieldsStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public PrimitiveFields mapFromCursor(@NonNull Cursor cursor) { + PrimitiveFields object = new PrimitiveFields(); + + object.floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + object.longField = cursor.getLong(cursor.getColumnIndex("longField")); + object.doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + object.booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + object.intField = cursor.getInt(cursor.getColumnIndex("intField")); + object.stringField = cursor.getString(cursor.getColumnIndex("stringField")); + object.shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + object.byteArrayField = cursor.getBlob(cursor.getColumnIndex("byteArrayField")); + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java new file mode 100644 index 000000000..e1dd9ac80 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java @@ -0,0 +1,57 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class PrimitiveFieldsStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull PrimitiveFields object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveFields object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.longField) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull PrimitiveFields object) { + ContentValues contentValues = new ContentValues(8); + + contentValues.put("floatField", object.floatField); + contentValues.put("longField", object.longField); + contentValues.put("doubleField", object.doubleField); + contentValues.put("booleanField", object.booleanField); + contentValues.put("intField", object.intField); + contentValues.put("stringField", object.stringField); + contentValues.put("shortField", object.shortField); + contentValues.put("byteArrayField", object.byteArrayField); + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java new file mode 100644 index 000000000..0cbb0537e --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java @@ -0,0 +1,74 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class PrimitiveMethodsConstructor { + + private boolean booleanField; + + private short shortField; + + private int intField; + + private long longField; + + private float floatField; + + private double doubleField; + + private String stringField; + + private byte[] byteArrayField; + + @StorIOSQLiteCreator + public PrimitiveMethodsConstructor(boolean booleanField, short shortField, int intField, long longField, float floatField, + double doubleField, String stringField, byte[] byteArrayField) { + this.booleanField = booleanField; + this.shortField = shortField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + this.stringField = stringField; + this.byteArrayField = byteArrayField; + } + + @StorIOSQLiteColumn(name = "booleanField") + public boolean isBooleanField() { + return booleanField; + } + + @StorIOSQLiteColumn(name = "shortField") + public short getShortField() { + return shortField; + } + + @StorIOSQLiteColumn(name = "intField") + public int getIntField() { + return intField; + } + + @StorIOSQLiteColumn(name = "longField", key = true) + public long getLongField() { + return longField; + } + + @StorIOSQLiteColumn(name = "floatField") + public float getFloatField() { + return floatField; + } + + @StorIOSQLiteColumn(name = "doubleField") + public double getDoubleField() { + return doubleField; + } + + @StorIOSQLiteColumn(name = "stringField") + public String getStringField() { + return stringField; + } + + @StorIOSQLiteColumn(name = "byteArrayField") + public byte[] getByteArrayField() { + return byteArrayField; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java new file mode 100644 index 000000000..388fbc27f --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class PrimitiveMethodsConstructorSQLiteTypeMapping extends SQLiteTypeMapping { + public PrimitiveMethodsConstructorSQLiteTypeMapping() { + super(new PrimitiveMethodsConstructorStorIOSQLitePutResolver(), + new PrimitiveMethodsConstructorStorIOSQLiteGetResolver(), + new PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..e6e84558d --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull PrimitiveMethodsConstructor object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..193b91b5b --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java @@ -0,0 +1,33 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; +import java.lang.String; + +/** + * Generated resolver for Get Operation + */ +public class PrimitiveMethodsConstructorStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public PrimitiveMethodsConstructor mapFromCursor(@NonNull Cursor cursor) { + + boolean booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + short shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + int intField = cursor.getInt(cursor.getColumnIndex("intField")); + long longField = cursor.getLong(cursor.getColumnIndex("longField")); + float floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + double doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + String stringField = cursor.getString(cursor.getColumnIndex("stringField")); + byte[] byteArrayField = cursor.getBlob(cursor.getColumnIndex("byteArrayField")); + + PrimitiveMethodsConstructor object = new PrimitiveMethodsConstructor(booleanField, shortField, intField, longField, floatField, doubleField, stringField, byteArrayField); + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java new file mode 100644 index 000000000..386d1dfd9 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java @@ -0,0 +1,57 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class PrimitiveMethodsConstructorStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull PrimitiveMethodsConstructor object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveMethodsConstructor object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull PrimitiveMethodsConstructor object) { + ContentValues contentValues = new ContentValues(8); + + contentValues.put("floatField", object.getFloatField()); + contentValues.put("longField", object.getLongField()); + contentValues.put("doubleField", object.getDoubleField()); + contentValues.put("booleanField", object.isBooleanField()); + contentValues.put("intField", object.getIntField()); + contentValues.put("stringField", object.getStringField()); + contentValues.put("shortField", object.getShortField()); + contentValues.put("byteArrayField", object.getByteArrayField()); + + return contentValues; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java new file mode 100644 index 000000000..7650f6839 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java @@ -0,0 +1,79 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +@StorIOSQLiteType(table = "table") +public class PrimitiveMethodsFactoryMethod { + + private boolean booleanField; + + private short shortField; + + private int intField; + + private long longField; + + private float floatField; + + private double doubleField; + + private String stringField; + + private byte[] byteArrayField; + + @StorIOSQLiteCreator + public static PrimitiveMethodsFactoryMethod create(boolean booleanField, short shortField, int intField, long longField, float floatField, + double doubleField, String stringField, byte[] byteArrayField) { + return new PrimitiveMethodsFactoryMethod(booleanField, shortField, intField, longField, floatField, doubleField, stringField, byteArrayField); + } + + private PrimitiveMethodsFactoryMethod(boolean booleanField, short shortField, int intField, long longField, float floatField, + double doubleField, String stringField, byte[] byteArrayField) { + this.booleanField = booleanField; + this.shortField = shortField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + this.stringField = stringField; + this.byteArrayField = byteArrayField; + } + + @StorIOSQLiteColumn(name = "booleanField") + public boolean isBooleanField() { + return booleanField; + } + + @StorIOSQLiteColumn(name = "shortField") + public short getShortField() { + return shortField; + } + + @StorIOSQLiteColumn(name = "intField") + public int getIntField() { + return intField; + } + + @StorIOSQLiteColumn(name = "longField", key = true) + public long getLongField() { + return longField; + } + + @StorIOSQLiteColumn(name = "floatField") + public float getFloatField() { + return floatField; + } + + @StorIOSQLiteColumn(name = "doubleField") + public double getDoubleField() { + return doubleField; + } + + @StorIOSQLiteColumn(name = "stringField") + public String getStringField() { + return stringField; + } + + @StorIOSQLiteColumn(name = "byteArrayField") + public byte[] getByteArrayField() { + return byteArrayField; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java new file mode 100644 index 000000000..d274364e9 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java @@ -0,0 +1,14 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; + +/** + * Generated mapping with collection of resolvers + */ +public class PrimitiveMethodsFactoryMethodSQLiteTypeMapping extends SQLiteTypeMapping { + public PrimitiveMethodsFactoryMethodSQLiteTypeMapping() { + super(new PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver(), + new PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver(), + new PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver()); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java new file mode 100644 index 000000000..32736bd95 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -0,0 +1,24 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; +import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; + +/** + * Generated resolver for Delete Operation + */ +public class PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public DeleteQuery mapToDeleteQuery(@NonNull PrimitiveMethodsFactoryMethod object) { + return DeleteQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java new file mode 100644 index 000000000..131681d64 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -0,0 +1,33 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.database.Cursor; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; +import java.lang.String; + +/** + * Generated resolver for Get Operation + */ +public class PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver extends DefaultGetResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public PrimitiveMethodsFactoryMethod mapFromCursor(@NonNull Cursor cursor) { + + boolean booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + short shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + int intField = cursor.getInt(cursor.getColumnIndex("intField")); + long longField = cursor.getLong(cursor.getColumnIndex("longField")); + float floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + double doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + String stringField = cursor.getString(cursor.getColumnIndex("stringField")); + byte[] byteArrayField = cursor.getBlob(cursor.getColumnIndex("byteArrayField")); + + PrimitiveMethodsFactoryMethod object = PrimitiveMethodsFactoryMethod.create(booleanField, shortField, intField, longField, floatField, doubleField, stringField, byteArrayField); + + return object; + } +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java new file mode 100644 index 000000000..a0c421ca5 --- /dev/null +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -0,0 +1,57 @@ +package com.pushtorefresh.storio.sqlite.annotations; + +import android.content.ContentValues; +import android.support.annotation.NonNull; +import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; +import com.pushtorefresh.storio.sqlite.queries.InsertQuery; +import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; + +/** + * Generated resolver for Put Operation + */ +public class PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver extends DefaultPutResolver { + /** + * {@inheritDoc} + */ + @Override + @NonNull + public InsertQuery mapToInsertQuery(@NonNull PrimitiveMethodsFactoryMethod object) { + return InsertQuery.builder() + .table("table") + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveMethodsFactoryMethod object) { + return UpdateQuery.builder() + .table("table") + .where("longField = ?") + .whereArgs(object.getLongField()) + .build(); + } + + /** + * {@inheritDoc} + */ + @Override + @NonNull + public ContentValues mapToContentValues(@NonNull PrimitiveMethodsFactoryMethod object) { + ContentValues contentValues = new ContentValues(8); + + contentValues.put("floatField", object.getFloatField()); + contentValues.put("longField", object.getLongField()); + contentValues.put("doubleField", object.getDoubleField()); + contentValues.put("booleanField", object.isBooleanField()); + contentValues.put("intField", object.getIntField()); + contentValues.put("stringField", object.getStringField()); + contentValues.put("shortField", object.getShortField()); + contentValues.put("byteArrayField", object.getByteArrayField()); + + return contentValues; + } +} From 0d5f2364c0137bb8d6a82162ff181b7499c6a331 Mon Sep 17 00:00:00 2001 From: Ilya Zorin Date: Sun, 5 Feb 2017 18:04:06 +0200 Subject: [PATCH 04/11] Remove redundant tests in common and sqlite processors --- .../processor/ProcessingExceptionTest.java | 40 ---- .../StorIOAnnotationsProcessorDummy.java | 120 ---------- ...StorIOAnnotationsProcessorProcessTest.java | 96 -------- .../StorIOAnnotationsProcessorTest.java | 51 ----- .../AnnotatedExecutableValidationTest.java | 65 ------ .../AnnotatedFieldValidationTest.java | 69 ------ .../AnnotationProcessorStub.java | 104 --------- ...sIgnoreNullStorIOSQLiteDeleteResolver.java | 2 +- ...eldsIgnoreNullStorIOSQLiteGetResolver.java | 2 +- ...eldsIgnoreNullStorIOSQLitePutResolver.java | 2 +- ...TypesFieldsStorIOSQLiteDeleteResolver.java | 2 +- ...xedTypesFieldsStorIOSQLiteGetResolver.java | 2 +- ...xedTypesFieldsStorIOSQLitePutResolver.java | 2 +- ...rIgnoreNullStorIOSQLiteDeleteResolver.java | 2 +- ...ctorIgnoreNullStorIOSQLiteGetResolver.java | 8 +- ...ctorIgnoreNullStorIOSQLitePutResolver.java | 2 +- ...ConstructorStorIOSQLiteDeleteResolver.java | 2 +- ...odsConstructorStorIOSQLiteGetResolver.java | 8 +- ...odsConstructorStorIOSQLitePutResolver.java | 2 +- ...dIgnoreNullStorIOSQLiteDeleteResolver.java | 2 +- ...thodIgnoreNullStorIOSQLiteGetResolver.java | 8 +- ...thodIgnoreNullStorIOSQLitePutResolver.java | 2 +- ...ctoryMethodStorIOSQLiteDeleteResolver.java | 2 +- ...sFactoryMethodStorIOSQLiteGetResolver.java | 8 +- ...sFactoryMethodStorIOSQLitePutResolver.java | 2 +- ...itiveFieldsStorIOSQLiteDeleteResolver.java | 2 +- ...rimitiveFieldsStorIOSQLiteGetResolver.java | 2 +- ...rimitiveFieldsStorIOSQLitePutResolver.java | 2 +- ...ConstructorStorIOSQLiteDeleteResolver.java | 2 +- ...odsConstructorStorIOSQLiteGetResolver.java | 3 +- ...odsConstructorStorIOSQLitePutResolver.java | 2 +- ...ctoryMethodStorIOSQLiteDeleteResolver.java | 2 +- ...sFactoryMethodStorIOSQLiteGetResolver.java | 3 +- ...sFactoryMethodStorIOSQLitePutResolver.java | 2 +- .../generate/DeleteResolverGeneratorTest.java | 87 ------- .../generate/GetResolverGeneratorTest.java | 178 --------------- .../generate/MappingGeneratorTest.java | 50 ----- .../generate/PutResolverGeneratorTest.java | 212 ------------------ .../generate/QueryGeneratorTest.java | 110 --------- .../processor/generate/TestFactory.java | 55 ----- 40 files changed, 27 insertions(+), 1290 deletions(-) delete mode 100644 storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/ProcessingExceptionTest.java delete mode 100644 storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorDummy.java delete mode 100644 storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorProcessTest.java delete mode 100644 storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorTest.java delete mode 100644 storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedExecutableValidationTest.java delete mode 100644 storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedFieldValidationTest.java delete mode 100644 storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotationProcessorStub.java delete mode 100644 storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGeneratorTest.java delete mode 100644 storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGeneratorTest.java delete mode 100644 storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGeneratorTest.java delete mode 100644 storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGeneratorTest.java delete mode 100644 storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/QueryGeneratorTest.java delete mode 100644 storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/TestFactory.java diff --git a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/ProcessingExceptionTest.java b/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/ProcessingExceptionTest.java deleted file mode 100644 index 9123612d2..000000000 --- a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/ProcessingExceptionTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.pushtorefresh.storio.common.annotations.processor; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.reflect.Whitebox.getInternalState; - -import javax.lang.model.element.Element; - -import org.junit.Before; -import org.junit.Test; - -public class ProcessingExceptionTest { - - private Element elementMock; - - @Before - public void setUp() throws Exception { - elementMock = mock(Element.class); - } - - @Test - public final void processingException() { - // when - ProcessingException processingException = new ProcessingException(elementMock, "TEST"); - - // then - assertThat("TEST").as("Constructor must be set detailMessage field.").isEqualTo(getInternalState(processingException, "detailMessage")); - assertThat(elementMock).as("Constructor must be set element field.").isEqualTo(getInternalState(processingException, "element")); - } - - @Test - public final void element() { - // when - ProcessingException processingException = new ProcessingException(elementMock, "TEST"); - - // then - assertThat(elementMock).as("Constructor must be set element field.").isEqualTo(processingException.element()); - } - -} diff --git a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorDummy.java b/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorDummy.java deleted file mode 100644 index 4167ed12a..000000000 --- a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorDummy.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.pushtorefresh.storio.common.annotations.processor; - -import com.pushtorefresh.storio.common.annotations.processor.generate.Generator; -import com.pushtorefresh.storio.common.annotations.processor.introspection.StorIOColumnMeta; -import com.pushtorefresh.storio.common.annotations.processor.introspection.StorIOTypeMeta; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.TypeSpec; - -import org.jetbrains.annotations.NotNull; - -import java.lang.annotation.Annotation; -import java.util.Map; - -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import javax.lang.model.util.Elements; - -@SuppressWarnings("rawtypes") -public final class StorIOAnnotationsProcessorDummy - extends StorIOAnnotationsProcessor { - - @Override - protected StorIOTypeMeta processAnnotatedClass(TypeElement classElement, Elements elementUtils) { - return null; - } - - @Override - protected void processAnnotatedFieldsOrMethods(RoundEnvironment roundEnvironment, Map annotatedClasses) { - } - - @Override - protected StorIOColumnMeta processAnnotatedFieldOrMethod(Element annotatedField) { - return null; - } - - @Override - protected void processAnnotatedExecutables(@NotNull RoundEnvironment roundEnvironment, @NotNull Map annotatedClasses) { - } - - @Override - protected void validateAnnotatedClassesAndColumns(Map annotatedClasses) { - } - - @Override - protected Class getTypeAnnotationClass() { - return Annotation.class; - } - - @Override - protected Class getColumnAnnotationClass() { - return null; - } - - @Override - protected Class getCreatorAnnotationClass() { - return null; - } - - @SuppressWarnings("unchecked") - @Override - protected Generator createPutResolver() { - Generator resolver = new Generator() { - - @Override - public JavaFile generateJavaFile(StorIOTypeMeta storIOContentResolverTypeMeta) { - final TypeSpec putResolver = TypeSpec.classBuilder("TEST").build(); - - return JavaFile.builder("TEST", putResolver).build(); - } - }; - return resolver; - } - - @SuppressWarnings("unchecked") - @Override - protected Generator createGetResolver() { - Generator resolver = new Generator() { - - @Override - public JavaFile generateJavaFile(StorIOTypeMeta storIOContentResolverTypeMeta) { - final TypeSpec getResolver = TypeSpec.classBuilder("TEST").build(); - - return JavaFile.builder("TEST", getResolver).build(); - } - }; - return resolver; - } - - @SuppressWarnings("unchecked") - @Override - protected Generator createDeleteResolver() { - Generator resolver = new Generator() { - - @Override - public JavaFile generateJavaFile(StorIOTypeMeta storIOContentResolverTypeMeta) { - final TypeSpec deleteResolver = TypeSpec.classBuilder("TEST").build(); - - return JavaFile.builder("TEST", deleteResolver).build(); - } - }; - return resolver; - } - - @SuppressWarnings("unchecked") - @Override - protected Generator createMapping() { - Generator mapping = new Generator() { - - @Override - public JavaFile generateJavaFile(StorIOTypeMeta storIOContentResolverTypeMeta) { - final TypeSpec mappingResolver = TypeSpec.classBuilder("TEST").build(); - - return JavaFile.builder("TEST", mappingResolver).build(); - } - }; - return mapping; - } - -} diff --git a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorProcessTest.java b/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorProcessTest.java deleted file mode 100644 index 968575a57..000000000 --- a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorProcessTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.pushtorefresh.storio.common.annotations.processor; - -import static javax.tools.Diagnostic.Kind.ERROR; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.verify; -import static org.assertj.core.api.Assertions.assertThat; -import static org.powermock.api.mockito.PowerMockito.doReturn; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; - -import java.io.Writer; -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import javax.annotation.processing.Filer; -import javax.annotation.processing.Messager; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; -import javax.lang.model.util.Elements; -import javax.tools.JavaFileObject; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import com.squareup.javapoet.JavaFile; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ JavaFile.class, JavaFileObject.class }) -public class StorIOAnnotationsProcessorProcessTest { - - private StorIOAnnotationsProcessorDummy storioAnnotationsProcessor; - private RoundEnvironment roundEnvironmentMock; - private TypeElement typeElementMock; - private ProcessingEnvironment processingEnvironment; - private Set elementsAnnotatedWithStorIOType; - - @Before - public void setUp() throws Exception { - storioAnnotationsProcessor = new StorIOAnnotationsProcessorDummy(); - roundEnvironmentMock = mock(RoundEnvironment.class); - typeElementMock = mock(TypeElement.class); - processingEnvironment = mock(ProcessingEnvironment.class); - elementsAnnotatedWithStorIOType = new HashSet(Arrays.asList(typeElementMock)); - doReturn(elementsAnnotatedWithStorIOType).when(roundEnvironmentMock).getElementsAnnotatedWith(Annotation.class); - } - - @Test - public final void processTrue() throws Exception { - // given - Elements elementUtilsMock = mock(Elements.class); - when(processingEnvironment.getElementUtils()).thenReturn(elementUtilsMock); - - Filer filerMock = mock(Filer.class); - when(processingEnvironment.getFiler()).thenReturn(filerMock); - - JavaFileObject javaFileObject = mock(JavaFileObject.class); - when(filerMock.createSourceFile(anyString())).thenReturn(javaFileObject); - - Writer writerMock = mock(Writer.class); - when(javaFileObject.openWriter()).thenReturn(writerMock); - - storioAnnotationsProcessor.init(processingEnvironment); - - // when - boolean result = storioAnnotationsProcessor.process(null, roundEnvironmentMock); - - // then - assertThat(result).isTrue(); - } - - @Test - public final void processExceptionExpected() throws Exception { - // given - Messager messager = mock(Messager.class); - when(processingEnvironment.getMessager()).thenReturn(messager); - - when(processingEnvironment.getFiler()).thenReturn(null); - - storioAnnotationsProcessor.init(processingEnvironment); - - // when - storioAnnotationsProcessor.process(null, roundEnvironmentMock); - - // then - // Filer value set to null, filerSourceFile can't be generated and - // problem occures. - verify(messager).printMessage(ERROR, "Problem occurred with StorIOProcessor: null"); - } -} diff --git a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorTest.java b/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorTest.java deleted file mode 100644 index 9d98a192d..000000000 --- a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.pushtorefresh.storio.common.annotations.processor; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.reflect.Whitebox.getInternalState; - -import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.SourceVersion; -import javax.tools.JavaFileObject; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import com.squareup.javapoet.JavaFile; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ JavaFile.class, JavaFileObject.class }) -public class StorIOAnnotationsProcessorTest { - - private StorIOAnnotationsProcessorDummy storioAnnotationsProcessor; - private ProcessingEnvironment processingEnvironment; - - @Before - public void setUp() throws Exception { - storioAnnotationsProcessor = new StorIOAnnotationsProcessorDummy(); - processingEnvironment = mock(ProcessingEnvironment.class); - } - - @Test - public final void initProcessingEnvironment() { - // when - storioAnnotationsProcessor.init(processingEnvironment); - - // then - assertThat(processingEnvironment.getFiler()).as("init must be set filer field.").isEqualTo(getInternalState(storioAnnotationsProcessor, "filer")); - assertThat(processingEnvironment.getElementUtils()).as("init must be set elementUtils field.").isEqualTo(getInternalState(storioAnnotationsProcessor, "elementUtils")); - assertThat(processingEnvironment.getMessager()).as("init must be set messager field.").isEqualTo(getInternalState(storioAnnotationsProcessor, "messager")); - } - - @Test - public final void getSupportedSourceVersion() { - // given - SourceVersion result = storioAnnotationsProcessor.getSupportedSourceVersion(); - - // then - assertThat(SourceVersion.latestSupported()).as("Function must return same result with SourceVersion.latestSupported() function.").isEqualTo(result); - } -} diff --git a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedExecutableValidationTest.java b/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedExecutableValidationTest.java deleted file mode 100644 index 3d0b86cfa..000000000 --- a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedExecutableValidationTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.pushtorefresh.storio.common.annotations.processor.introspection; - -import com.pushtorefresh.storio.common.annotations.processor.ProcessingException; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.HashSet; -import java.util.Set; - -import javax.lang.model.element.Modifier; - -import static javax.lang.model.element.ElementKind.METHOD; -import static org.mockito.Mockito.when; - -public class AnnotatedExecutableValidationTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void failIfEnclosingElementIsNotClass() { - AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); - when(stub.enclosingElement.getKind()).thenReturn(METHOD); - - expectedException.expect(ProcessingException.class); - expectedException.expectMessage("Please apply TestCreatorAnnotation to constructor or factory method of class: TestClass"); - stub.processor.validateAnnotatedExecutable(stub.creator); - } - - @Test - public void failIfThereIsNoAnnotation() { - AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); - when(stub.enclosingElement.getAnnotation(AnnotationProcessorStub.TestClassAnnotation.class)).thenReturn(null); - - expectedException.expect(ProcessingException.class); - expectedException.expectMessage("Please annotate class TestClass with TestClassAnnotation"); - stub.processor.validateAnnotatedExecutable(stub.creator); - } - - @Test - public void failIfExecutablePrivate() { - AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); - Set modifiers = new HashSet(); - modifiers.add(Modifier.PRIVATE); - when(stub.creator.getModifiers()).thenReturn(modifiers); - - expectedException.expect(ProcessingException.class); - expectedException.expectMessage("TestCreatorAnnotation can not be applied to private methods or constructors"); - stub.processor.validateAnnotatedExecutable(stub.creator); - } - - @Test - public void failIfFactoryMethodNotStatic() { - AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); - Set modifiers = new HashSet(); - when(stub.creator.getModifiers()).thenReturn(modifiers); - when(stub.creator.getKind()).thenReturn(METHOD); - - expectedException.expect(ProcessingException.class); - expectedException.expectMessage("TestCreatorAnnotation can not be applied to non-static methods"); - stub.processor.validateAnnotatedExecutable(stub.creator); - } -} diff --git a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedFieldValidationTest.java b/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedFieldValidationTest.java deleted file mode 100644 index 3223e44f7..000000000 --- a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotatedFieldValidationTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.pushtorefresh.storio.common.annotations.processor.introspection; - -import com.pushtorefresh.storio.common.annotations.processor.ProcessingException; -import com.pushtorefresh.storio.common.annotations.processor.SkipNotAnnotatedClassWithAnnotatedParentException; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.HashSet; -import java.util.Set; - -import javax.lang.model.element.Modifier; - -import static javax.lang.model.element.ElementKind.FIELD; -import static javax.lang.model.element.ElementKind.METHOD; -import static org.mockito.Mockito.when; - -public class AnnotatedFieldValidationTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void failIfEnclosingElementIsNotType() throws SkipNotAnnotatedClassWithAnnotatedParentException { - AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); - when(stub.enclosingElement.getKind()).thenReturn(METHOD); - - expectedException.expect(ProcessingException.class); - expectedException.expectMessage("Please apply TestFieldAnnotation to fields or methods of class: TestField"); - stub.processor.validateAnnotatedFieldOrMethod(stub.field); - } - -// @Test -// public void failIfThereIsNoAnnotation() { -// AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); -// when(stub.enclosingElement.getAnnotation(AnnotationProcessorStub.TestClassAnnotation.class)).thenReturn(null); -// -// expectedException.expect(ProcessingException.class); -// expectedException.expectMessage("Please annotate class TestClass with TestClassAnnotation"); -// stub.processor.validateAnnotatedFieldOrMethod(stub.field); -// } - - @Test - public void failIfFieldPrivate() throws SkipNotAnnotatedClassWithAnnotatedParentException { - AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); - Set modifiers = new HashSet(); - modifiers.add(Modifier.PRIVATE); - when(stub.field.getModifiers()).thenReturn(modifiers); - when(stub.field.getKind()).thenReturn(FIELD); - - expectedException.expect(ProcessingException.class); - expectedException.expectMessage("TestFieldAnnotation can not be applied to private field or method: TestField"); - stub.processor.validateAnnotatedFieldOrMethod(stub.field); - } - - @Test - public void failIfFieldFinal() throws SkipNotAnnotatedClassWithAnnotatedParentException { - AnnotationProcessorStub stub = AnnotationProcessorStub.newInstance(); - Set modifiers = new HashSet(); - modifiers.add(Modifier.FINAL); - when(stub.field.getModifiers()).thenReturn(modifiers); - when(stub.field.getKind()).thenReturn(FIELD); - - expectedException.expect(ProcessingException.class); - expectedException.expectMessage("TestFieldAnnotation can not be applied to final field: TestField"); - stub.processor.validateAnnotatedFieldOrMethod(stub.field); - } -} diff --git a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotationProcessorStub.java b/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotationProcessorStub.java deleted file mode 100644 index ff06092b6..000000000 --- a/storio-common-annotations-processor/src/test/java/com/pushtorefresh/storio/common/annotations/processor/introspection/AnnotationProcessorStub.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.pushtorefresh.storio.common.annotations.processor.introspection; - -import com.pushtorefresh.storio.common.annotations.processor.SkipNotAnnotatedClassWithAnnotatedParentException; -import com.pushtorefresh.storio.common.annotations.processor.StorIOAnnotationsProcessor; - -import org.jetbrains.annotations.NotNull; -import org.mockito.Mockito; - -import java.lang.annotation.Annotation; - -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Name; - -import static javax.lang.model.element.ElementKind.CLASS; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class AnnotationProcessorStub { - - final TestStorIOAnnotationsProcessor processor; - final Element field; - final ExecutableElement creator; - final Element enclosingElement; - final TestClassAnnotation classAnnotation; - final TestFieldAnnotation fieldAnnotation; - final TestCreatorAnnotation creatorAnnotation; - - @NotNull - static AnnotationProcessorStub newInstance() { - return new AnnotationProcessorStub(); - } - - public AnnotationProcessorStub() { - processor = mock(TestStorIOAnnotationsProcessor.class, Mockito.CALLS_REAL_METHODS); - - field = mock(Element.class); - - Name fieldName = mock(Name.class); - when(fieldName.toString()).thenReturn("TestField"); - when(field.getSimpleName()).thenReturn(fieldName); - - creator = mock(ExecutableElement.class); - - Name creatorName = mock(Name.class); - when(creatorName.toString()).thenReturn("TestCreator"); - when(creator.getSimpleName()).thenReturn(creatorName); - - enclosingElement = mock(Element.class); - Name className = mock(Name.class); - when(className.toString()).thenReturn("TestClass"); - when(enclosingElement.getSimpleName()).thenReturn(className); - when(enclosingElement.getKind()).thenReturn(CLASS); - - when(field.getEnclosingElement()).thenReturn(enclosingElement); - when(creator.getEnclosingElement()).thenReturn(enclosingElement); - - classAnnotation = mock(TestClassAnnotation.class); - fieldAnnotation = mock(TestFieldAnnotation.class); - creatorAnnotation = mock(TestCreatorAnnotation.class); - - when(enclosingElement.getAnnotation(TestClassAnnotation.class)).thenReturn(classAnnotation); - } - - protected static abstract class TestStorIOAnnotationsProcessor extends StorIOAnnotationsProcessor { - - @Override - public void validateAnnotatedFieldOrMethod(@NotNull Element annotatedElement) throws SkipNotAnnotatedClassWithAnnotatedParentException { - super.validateAnnotatedFieldOrMethod(annotatedElement); - } - - @Override - protected void validateAnnotatedExecutable(@NotNull ExecutableElement annotatedElement) { - super.validateAnnotatedExecutable(annotatedElement); - } - - @NotNull - @Override - public Class getTypeAnnotationClass() { - return TestClassAnnotation.class; - } - - @NotNull - @Override - protected Class getColumnAnnotationClass() { - return TestFieldAnnotation.class; - } - - @NotNull - @Override - protected Class getCreatorAnnotationClass() { - return TestCreatorAnnotation.class; - } - } - - static abstract class TestClassAnnotation implements Annotation { - } - - static abstract class TestFieldAnnotation implements Annotation { - } - - static abstract class TestCreatorAnnotation implements Annotation { - } -} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java index a4b1d6778..e8d429e29 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java index 02ccf9554..bf1c41bd6 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java @@ -2,8 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Override; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java index 4cf26a560..aaa8534f9 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java index b2be3f3dc..dd5361533 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java index 786bfae4e..274ec28f4 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java @@ -2,8 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Override; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java index 20a1897ed..408c15365 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java index e6056cd05..024f8a461 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java index e09039295..a6957b2fb 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java @@ -2,14 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Boolean; -import java.lang.Double; -import java.lang.Float; -import java.lang.Integer; -import java.lang.Long; -import java.lang.Override; -import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java index a47c4eb6e..177c562fb 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java index 1f84d4b08..efbfa8fc7 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java index d638045fe..e44de1380 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java @@ -2,14 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Boolean; -import java.lang.Double; -import java.lang.Float; -import java.lang.Integer; -import java.lang.Long; -import java.lang.Override; -import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java index 5b42048c1..7435d73cf 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java index e981180e6..583b03d5d 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java index f6db8ed76..ef333806f 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java @@ -2,14 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Boolean; -import java.lang.Double; -import java.lang.Float; -import java.lang.Integer; -import java.lang.Long; -import java.lang.Override; -import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java index dcd94ebb8..7e0ae6686 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java index f567b4e87..91b9ce298 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java index 509594132..2ce0e1904 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -2,14 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Boolean; -import java.lang.Double; -import java.lang.Float; -import java.lang.Integer; -import java.lang.Long; -import java.lang.Override; -import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java index ff08af1e6..f6c4f45b6 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java index 25ecdcc86..293016281 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java index 5a4c0ef7a..78173d8ca 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java @@ -2,8 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Override; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java index e1dd9ac80..073f814fd 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java index e6e84558d..a6d9c58b9 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java index 193b91b5b..8cf31bf4e 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java @@ -2,9 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Override; -import java.lang.String; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java index 386d1dfd9..add016786 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java index 32736bd95..a24ec0b13 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; -import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java index 131681d64..7ebd95a81 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -2,9 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; -import java.lang.Override; -import java.lang.String; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java index a0c421ca5..3f42381c5 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; + import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; -import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGeneratorTest.java b/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGeneratorTest.java deleted file mode 100644 index 621614bb7..000000000 --- a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGeneratorTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.pushtorefresh.storio.sqlite.annotations.processor.generate; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteColumnMeta; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteTypeMeta; -import com.squareup.javapoet.JavaFile; - -import org.junit.Test; - -import java.io.IOException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class DeleteResolverGeneratorTest { - - @Test - public void generateJavaFile() throws IOException { - final StorIOSQLiteType storIOSQLiteType = mock(StorIOSQLiteType.class); - - when(storIOSQLiteType.table()).thenReturn("test_table"); - - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta( - "TestItem", - "com.test", - storIOSQLiteType, - false - ); - - final StorIOSQLiteColumn storIOSQLiteColumn1 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn1.name()).thenReturn("column1"); - - //noinspection ConstantConditions - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta1 = new StorIOSQLiteColumnMeta( - null, - null, - "field1", - null, - storIOSQLiteColumn1 - ); - storIOSQLiteTypeMeta.columns.put("column1", storIOSQLiteColumnMeta1); - - final StorIOSQLiteColumn storIOSQLiteColumn2 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn2.name()).thenReturn("column2"); - - //noinspection ConstantConditions - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta2 = new StorIOSQLiteColumnMeta( - null, - null, - "field2", - null, - storIOSQLiteColumn2 - ); - storIOSQLiteTypeMeta.columns.put("column2", storIOSQLiteColumnMeta2); - - final JavaFile javaFile = new DeleteResolverGenerator().generateJavaFile(storIOSQLiteTypeMeta); - final StringBuilder out = new StringBuilder(); - javaFile.writeTo(out); - - assertThat(out.toString()).isEqualTo("package com.test;\n" + - "\n" + - "import android.support.annotation.NonNull;\n" + - "import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver;\n" + - "import com.pushtorefresh.storio.sqlite.queries.DeleteQuery;\n" + - "import java.lang.Override;\n" + - "\n" + - "/**\n" + - " * Generated resolver for Delete Operation\n" + - " */\n" + - "public class TestItemStorIOSQLiteDeleteResolver extends DefaultDeleteResolver {\n" + - " /**\n" + - " * {@inheritDoc}\n" + - " */\n" + - " @Override\n" + - " @NonNull\n" + - " public DeleteQuery mapToDeleteQuery(@NonNull TestItem object) {\n" + - " return DeleteQuery.builder()\n" + - " .table(\"test_table\")\n" + - " .where(null)\n" + - " .whereArgs(null)\n" + - " .build();\n" + - " }\n" + - "}\n"); - } -} diff --git a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGeneratorTest.java b/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGeneratorTest.java deleted file mode 100644 index 6c4bd9e4e..000000000 --- a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGeneratorTest.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.pushtorefresh.storio.sqlite.annotations.processor.generate; - -import com.pushtorefresh.storio.common.annotations.processor.introspection.JavaType; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteColumnMeta; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteTypeMeta; -import com.squareup.javapoet.JavaFile; - -import org.jetbrains.annotations.NotNull; -import org.junit.Test; - -import java.io.IOException; - -import javax.lang.model.type.TypeKind; - -import static com.pushtorefresh.storio.sqlite.annotations.processor.generate.TestFactory.createColumnMetaMock; -import static com.pushtorefresh.storio.sqlite.annotations.processor.generate.TestFactory.createElementMock; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class GetResolverGeneratorTest { - - @NotNull - private static final String PART_PACKAGE = "package com.test;\n\n"; - - @NotNull - private static final String PART_IMPORT = - "import android.database.Cursor;\n" + - "import android.support.annotation.NonNull;\n" + - "import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver;\n" + - "import java.lang.Override;\n" + - "\n"; - - @NotNull - private static final String PART_CLASS = - "/**\n" + - " * Generated resolver for Get Operation\n" + - " */\n" + - "public class TestItemStorIOSQLiteGetResolver extends DefaultGetResolver {\n"; - - @NotNull - private static final String PART_MAP_FROM_CURSOR_WITHOUT_NULL_CHECK = - " /**\n" + - " * {@inheritDoc}\n" + - " */\n" + - " @Override\n" + - " @NonNull\n" + - " public TestItem mapFromCursor(@NonNull Cursor cursor) {\n" + - " TestItem object = new TestItem();\n" + - "\n" + - " object.field1 = cursor.getInt(cursor.getColumnIndex(\"column1\")) == 1;\n" + - " object.field2 = cursor.getString(cursor.getColumnIndex(\"column2\"));\n" + - "\n" + - " return object;\n" + - " }\n"; - - @Test - public void generateJavaFileTest() throws IOException { - final StorIOSQLiteType storIOSQLiteType = mock(StorIOSQLiteType.class); - - when(storIOSQLiteType.table()).thenReturn("test_table"); - - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta( - "TestItem", - "com.test", - storIOSQLiteType, - false - ); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta1 = createColumnMetaMock( - createElementMock(TypeKind.BOOLEAN), - "column1", - "field1", - true, // key - false, - JavaType.BOOLEAN - ); - storIOSQLiteTypeMeta.columns.put("column1", storIOSQLiteColumnMeta1); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta2 = createColumnMetaMock( - createElementMock(TypeKind.OTHER), - "column2", - "field2", - false, - false, - JavaType.STRING - ); - storIOSQLiteTypeMeta.columns.put("column2", storIOSQLiteColumnMeta2); - - final JavaFile javaFile = new GetResolverGenerator().generateJavaFile(storIOSQLiteTypeMeta); - final StringBuilder out = new StringBuilder(); - javaFile.writeTo(out); - - checkFile( - out.toString(), - PART_PACKAGE, - PART_IMPORT, - PART_CLASS, - PART_MAP_FROM_CURSOR_WITHOUT_NULL_CHECK - ); - } - - @Test - public void checksForNullIfBoxedType() throws IOException { - final StorIOSQLiteType storIOSQLiteType = mock(StorIOSQLiteType.class); - - when(storIOSQLiteType.table()).thenReturn("test_table"); - - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta( - "TestItem", - "com.test", - storIOSQLiteType, - false - ); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta1 = createColumnMetaMock( - createElementMock(TypeKind.BOOLEAN), - "column1", - "field1", - true, // key - false, - JavaType.BOOLEAN - ); - storIOSQLiteTypeMeta.columns.put("column1", storIOSQLiteColumnMeta1); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta2 = createColumnMetaMock( - createElementMock(TypeKind.OTHER), - "column2", - "field2", - false, - false, - JavaType.INTEGER_OBJECT // boxed type - ); - storIOSQLiteTypeMeta.columns.put("column2", storIOSQLiteColumnMeta2); - - final JavaFile javaFile = new GetResolverGenerator().generateJavaFile(storIOSQLiteTypeMeta); - final StringBuilder out = new StringBuilder(); - javaFile.writeTo(out); - - checkFile( - out.toString(), - PART_PACKAGE, - PART_IMPORT, - PART_CLASS, - " /**\n" + - " * {@inheritDoc}\n" + - " */\n" + - " @Override\n" + - " @NonNull\n" + - " public TestItem mapFromCursor(@NonNull Cursor cursor) {\n" + - " TestItem object = new TestItem();\n" + - "\n" + - " object.field1 = cursor.getInt(cursor.getColumnIndex(\"column1\")) == 1;\n" + - " if (!cursor.isNull(cursor.getColumnIndex(\"column2\"))) {\n" + - " object.field2 = cursor.getInt(cursor.getColumnIndex(\"column2\"));\n" + - " }\n" + - "\n" + - " return object;\n" + - " }\n" - ); - } - - private void checkFile( - @NotNull String actualFile, - @NotNull String partPackage, - @NotNull String partImport, - @NotNull String partClass, - @NotNull String partMapFromCursor - ) { - assertThat(actualFile).isEqualTo( - partPackage + - partImport + - partClass + - partMapFromCursor + - "}\n"); - } -} diff --git a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGeneratorTest.java b/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGeneratorTest.java deleted file mode 100644 index 2367f7c0a..000000000 --- a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGeneratorTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.pushtorefresh.storio.sqlite.annotations.processor.generate; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteTypeMeta; -import com.squareup.javapoet.JavaFile; - -import org.junit.Test; - -import java.io.IOException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -public class MappingGeneratorTest { - @Test - public void generateJavaFile() throws IOException { - final StorIOSQLiteType storIOSQLiteType = mock(StorIOSQLiteType.class); - - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta( - "TestItem", - "com.test", - storIOSQLiteType, - false - ); - - MappingGenerator mappingGenerator = new MappingGenerator(); - final JavaFile javaFile = mappingGenerator.generateJavaFile(storIOSQLiteTypeMeta); - final StringBuilder out = new StringBuilder(); - javaFile.writeTo(out); - - - String result = - "package com.test;\n" + - "\n" + - "import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping;\n" + - "\n" + - "/**\n" + - " * Generated mapping with collection of resolvers\n" + - " */\n" + - "public class TestItemSQLiteTypeMapping extends SQLiteTypeMapping {\n" + - " public TestItemSQLiteTypeMapping() {\n" + - " super(new TestItemStorIOSQLitePutResolver(),\n" + - " new TestItemStorIOSQLiteGetResolver(),\n" + - " new TestItemStorIOSQLiteDeleteResolver());\n" + - " }\n" + - "}\n"; - - assertThat(out.toString()).isEqualTo(result); - } -} \ No newline at end of file diff --git a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGeneratorTest.java b/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGeneratorTest.java deleted file mode 100644 index fb98ee095..000000000 --- a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGeneratorTest.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.pushtorefresh.storio.sqlite.annotations.processor.generate; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteColumnMeta; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteTypeMeta; -import com.squareup.javapoet.JavaFile; - -import org.jetbrains.annotations.NotNull; -import org.junit.Test; - -import java.io.IOException; - -import javax.lang.model.element.Element; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import static com.pushtorefresh.storio.sqlite.annotations.processor.generate.TestFactory.createColumnMetaMock; -import static javax.lang.model.type.TypeKind.NONE; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class PutResolverGeneratorTest { - - @NotNull - private static final String PART_PACKAGE = "package com.test;\n\n"; - - @NotNull - private static final String PART_IMPORT = - "import android.content.ContentValues;\n" + - "import android.support.annotation.NonNull;\n" + - "import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver;\n" + - "import com.pushtorefresh.storio.sqlite.queries.InsertQuery;\n" + - "import com.pushtorefresh.storio.sqlite.queries.UpdateQuery;\n" + - "import java.lang.Override;\n" + - "\n"; - - @NotNull - private static final String PART_CLASS = - "/**\n" + - " * Generated resolver for Put Operation\n" + - " */\n" + - "public class TestItemStorIOSQLitePutResolver extends DefaultPutResolver {\n"; - - @NotNull - private static final String PART_MAP_TO_INSERT_QUERY = - " /**\n" + - " * {@inheritDoc}\n" + - " */\n" + - " @Override\n" + - " @NonNull\n" + - " public InsertQuery mapToInsertQuery(@NonNull TestItem object) {\n" + - " return InsertQuery.builder()\n" + - " .table(\"test_table\")\n" + - " .build();\n" + - " }\n" + - "\n"; - - @NotNull - private static final String PART_MAP_TO_UPDATE_QUERY = - " /**\n" + - " * {@inheritDoc}\n" + - " */\n" + - " @Override\n" + - " @NonNull\n" + - " public UpdateQuery mapToUpdateQuery(@NonNull TestItem object) {\n" + - " return UpdateQuery.builder()\n" + - " .table(\"test_table\")\n" + - " .where(\"column1 = ?\")\n" + - " .whereArgs(object.column1Field)\n" + - " .build();\n" + - " }\n" + - "\n"; - - @NotNull - private static final String PART_MAP_TO_CONTENT_VALUES_WITHOUT_NULL_CHECK = - " /**\n" + - " * {@inheritDoc}\n" + - " */\n" + - " @Override\n" + - " @NonNull\n" + - " public ContentValues mapToContentValues(@NonNull TestItem object) {\n" + - " ContentValues contentValues = new ContentValues(2);\n" + - "\n" + - " contentValues.put(\"column1\", object.column1Field);\n" + - " contentValues.put(\"column2\", object.column2Field);\n" + - "\n" + - " return contentValues;\n" + - " }\n"; - - @Test - public void generateJavaFile() throws IOException { - final StorIOSQLiteType storIOSQLiteType = mock(StorIOSQLiteType.class); - - when(storIOSQLiteType.table()).thenReturn("test_table"); - - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta("TestItem", "com.test", storIOSQLiteType, false); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta1 = createColumnMetaMock( - createElementMock(NONE), - "column1", - "column1Field", - true, // key - false, - null); - storIOSQLiteTypeMeta.columns.put("column1", storIOSQLiteColumnMeta1); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta2 = createColumnMetaMock( - createElementMock(NONE), - "column2", - "column2Field", - false, - false, - null); - storIOSQLiteTypeMeta.columns.put("column2", storIOSQLiteColumnMeta2); - - final PutResolverGenerator putResolverGenerator = new PutResolverGenerator(); - final JavaFile javaFile = putResolverGenerator.generateJavaFile(storIOSQLiteTypeMeta); - final StringBuilder out = new StringBuilder(); - javaFile.writeTo(out); - - checkFile(out.toString(), - PART_PACKAGE, - PART_IMPORT, - PART_CLASS, - PART_MAP_TO_INSERT_QUERY, - PART_MAP_TO_UPDATE_QUERY, - PART_MAP_TO_CONTENT_VALUES_WITHOUT_NULL_CHECK); - } - - @Test - public void ignoreNullsShouldAddCheck() throws IOException { - final StorIOSQLiteType storIOSQLiteType = mock(StorIOSQLiteType.class); - - when(storIOSQLiteType.table()).thenReturn("test_table"); - - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta("TestItem", "com.test", storIOSQLiteType, false); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta1 = createColumnMetaMock( - createElementMock(NONE), - "column1", - "column1Field", - true, - false, - null); - storIOSQLiteTypeMeta.columns.put("column1", storIOSQLiteColumnMeta1); - - final StorIOSQLiteColumnMeta storIOSQLiteColumnMeta2 = createColumnMetaMock( - createElementMock(NONE), // not a primitive - "column2", - "column2Field", - false, - true, - null); // ignore nulls - storIOSQLiteTypeMeta.columns.put("column2", storIOSQLiteColumnMeta2); - - final PutResolverGenerator putResolverGenerator = new PutResolverGenerator(); - final JavaFile javaFile = putResolverGenerator.generateJavaFile(storIOSQLiteTypeMeta); - final StringBuilder out = new StringBuilder(); - javaFile.writeTo(out); - - checkFile(out.toString(), - PART_PACKAGE, - PART_IMPORT, - PART_CLASS, - PART_MAP_TO_INSERT_QUERY, - PART_MAP_TO_UPDATE_QUERY, - " /**\n" + - " * {@inheritDoc}\n" + - " */\n" + - " @Override\n" + - " @NonNull\n" + - " public ContentValues mapToContentValues(@NonNull TestItem object) {\n" + - " ContentValues contentValues = new ContentValues(2);\n" + - "\n" + - " contentValues.put(\"column1\", object.column1Field);\n" + - " if (object.column2Field != null) {\n" + // check for null added - " contentValues.put(\"column2\", object.column2Field);\n" + - " }\n" + - "\n" + - " return contentValues;\n" + - " }\n"); - } - - @NotNull - private static Element createElementMock(@NotNull TypeKind typeKind) { - final Element objectElement = mock(Element.class); - final TypeMirror typeMirror = mock(TypeMirror.class); - when(objectElement.asType()).thenReturn(typeMirror); - when(typeMirror.getKind()).thenReturn(typeKind); - return objectElement; - } - - private void checkFile( - @NotNull String actualFile, - @NotNull String partPackage, - @NotNull String partImport, - @NotNull String partClass, - @NotNull String partMapToInsertQuery, - @NotNull String partMapToUpdateQuery, - @NotNull String partMapToContentValues - ) { - assertThat(actualFile).isEqualTo( - partPackage + - partImport + - partClass + - partMapToInsertQuery + - partMapToUpdateQuery + - partMapToContentValues + - "}\n"); - } -} diff --git a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/QueryGeneratorTest.java b/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/QueryGeneratorTest.java deleted file mode 100644 index beeea4a14..000000000 --- a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/QueryGeneratorTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.pushtorefresh.storio.sqlite.annotations.processor.generate; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteColumnMeta; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteTypeMeta; - -import org.junit.Test; - -import java.util.Collections; -import java.util.Map; - -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class QueryGeneratorTest { - - @Test - public void createWhereNullStorIOSQLiteTypeMeta() { - try { - //noinspection ConstantConditions - QueryGenerator.createWhere(null, "object"); - failBecauseExceptionWasNotThrown(NullPointerException.class); - } catch (NullPointerException expected) { - assertThat(expected).hasNoCause(); - } - } - - @Test - public void createWhereNoColumns() { - //noinspection ConstantConditions - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta(null, null, null, false); - assertThat(QueryGenerator.createWhere(storIOSQLiteTypeMeta, "object")).isEqualTo(Collections.emptyMap()); - } - - @SuppressWarnings("ConstantConditions") - @Test - public void createWhereNoKeyColumns() { - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta(null, null, null, false); - - final StorIOSQLiteColumn storIOSQLiteColumn1 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn1.key()).thenReturn(false); - storIOSQLiteTypeMeta.columns.put("column1", new StorIOSQLiteColumnMeta(null, null, null, null, storIOSQLiteColumn1)); - - final StorIOSQLiteColumn storIOSQLiteColumn2 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn2.key()).thenReturn(false); - storIOSQLiteTypeMeta.columns.put("column2", new StorIOSQLiteColumnMeta(null, null, null, null, storIOSQLiteColumn2)); - - assertThat(QueryGenerator.createWhere(storIOSQLiteTypeMeta, "object")).isEqualTo(Collections.emptyMap()); - } - - @SuppressWarnings("ConstantConditions") - @Test - public void createWhereOneKeyColumn() { - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta(null, null, null, false); - - final Element element = mock(Element.class); - when(element.getKind()).thenReturn(ElementKind.FIELD); - - final StorIOSQLiteColumn storIOSQLiteColumn1 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn1.key()).thenReturn(false); - storIOSQLiteTypeMeta.columns.put("column1", new StorIOSQLiteColumnMeta(null, element, null, null, storIOSQLiteColumn1)); - - final StorIOSQLiteColumn storIOSQLiteColumn2 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn2.key()).thenReturn(true); - when(storIOSQLiteColumn2.name()).thenReturn("column2"); - storIOSQLiteTypeMeta.columns.put("column2", new StorIOSQLiteColumnMeta(null, element, "testField1", null, storIOSQLiteColumn2)); - - final StorIOSQLiteColumn storIOSQLiteColumn3 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn3.key()).thenReturn(false); - storIOSQLiteTypeMeta.columns.put("column3", new StorIOSQLiteColumnMeta(null, element, null, null, storIOSQLiteColumn3)); - - final Map where = QueryGenerator.createWhere(storIOSQLiteTypeMeta, "object"); - - assertThat(where.get(QueryGenerator.WHERE_CLAUSE)).isEqualTo("column2 = ?"); - assertThat(where.get(QueryGenerator.WHERE_ARGS)).isEqualTo("object.testField1"); - } - - @SuppressWarnings("ConstantConditions") - @Test - public void createWhereMultipleKeyColumns() { - final StorIOSQLiteTypeMeta storIOSQLiteTypeMeta = new StorIOSQLiteTypeMeta(null, null, null, false); - - final Element element = mock(Element.class); - when(element.getKind()).thenReturn(ElementKind.FIELD); - - final StorIOSQLiteColumn storIOSQLiteColumn1 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn1.key()).thenReturn(true); - when(storIOSQLiteColumn1.name()).thenReturn("column1"); - storIOSQLiteTypeMeta.columns.put("column1", new StorIOSQLiteColumnMeta(null, element, "testField1", null, storIOSQLiteColumn1)); - - final StorIOSQLiteColumn storIOSQLiteColumn2 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn2.key()).thenReturn(false); - storIOSQLiteTypeMeta.columns.put("column2", new StorIOSQLiteColumnMeta(null, element, null, null, storIOSQLiteColumn2)); - - final StorIOSQLiteColumn storIOSQLiteColumn3 = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn3.key()).thenReturn(true); - when(storIOSQLiteColumn3.name()).thenReturn("column3"); - storIOSQLiteTypeMeta.columns.put("column3", new StorIOSQLiteColumnMeta(null, element, "testField3", null, storIOSQLiteColumn3)); - - final Map where = QueryGenerator.createWhere(storIOSQLiteTypeMeta, "object"); - - assertThat(where.get(QueryGenerator.WHERE_CLAUSE)).isEqualTo("column1 = ? AND column3 = ?"); - assertThat(where.get(QueryGenerator.WHERE_ARGS)).isEqualTo("object.testField1, object.testField3"); - } -} diff --git a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/TestFactory.java b/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/TestFactory.java deleted file mode 100644 index 0f0583069..000000000 --- a/storio-sqlite-annotations-processor/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/TestFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.pushtorefresh.storio.sqlite.annotations.processor.generate; - -import com.pushtorefresh.storio.common.annotations.processor.introspection.JavaType; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.processor.introspection.StorIOSQLiteColumnMeta; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.lang.model.element.Element; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public final class TestFactory { - - private TestFactory() { - throw new IllegalStateException("No instances please"); - } - - @NotNull - public static Element createElementMock(@NotNull TypeKind typeKind) { - final Element objectElement = mock(Element.class); - final TypeMirror typeMirror = mock(TypeMirror.class); - when(objectElement.asType()).thenReturn(typeMirror); - when(typeMirror.getKind()).thenReturn(typeKind); - return objectElement; - } - - @NotNull - public static StorIOSQLiteColumnMeta createColumnMetaMock( - @NotNull Element element, - @NotNull String columnName, - @NotNull String fieldName, - boolean isKey, - boolean ignoreNull, - @Nullable JavaType javaType) { - - final StorIOSQLiteColumn storIOSQLiteColumn = mock(StorIOSQLiteColumn.class); - when(storIOSQLiteColumn.name()).thenReturn(columnName); - when(storIOSQLiteColumn.key()).thenReturn(isKey); - when(storIOSQLiteColumn.ignoreNull()).thenReturn(ignoreNull); - - //noinspection ConstantConditions - return new StorIOSQLiteColumnMeta( - null, - element, - fieldName, - javaType, - storIOSQLiteColumn - ); - } -} From a0f76c6b2737e963ba0f1392278dc62779455e92 Mon Sep 17 00:00:00 2001 From: Ilya Zorin Date: Sun, 5 Feb 2017 18:11:14 +0200 Subject: [PATCH 05/11] Fix settings.gradle formatting --- settings.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 531a8ea7c..753076cf8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include ':storio-common', ':storio-sqlite-annotations-processor-test' +include ':storio-common' include ':storio-test-common' include ':storio-sqlite' include ':storio-content-resolver' @@ -8,6 +8,7 @@ include ':storio-content-resolver-annotations' include ':storio-common-annotations-processor' include ':storio-sqlite-annotations-processor' +include ':storio-sqlite-annotations-processor-test' include ':storio-content-resolver-annotations-processor' include ':storio-test-without-rxjava' From 32cea7a29feb2f3c22b3299a78e8e19a224f8af5 Mon Sep 17 00:00:00 2001 From: geralt-encore Date: Mon, 6 Feb 2017 11:25:15 +0200 Subject: [PATCH 06/11] getRuntimeJar workaround --- .../build.gradle | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/storio-sqlite-annotations-processor-test/build.gradle b/storio-sqlite-annotations-processor-test/build.gradle index a3aed3cd5..08773b56f 100644 --- a/storio-sqlite-annotations-processor-test/build.gradle +++ b/storio-sqlite-annotations-processor-test/build.gradle @@ -16,6 +16,20 @@ dependencies { testCompile libraries.storIOSQLite testCompile libraries.storIOSQLiteAnnotationsProcessor testCompile libraries.googleTestingCompile - testCompile files(Jvm.current().getRuntimeJar()) + testCompile files(getRuntimeJar()) testCompile files(Jvm.current().getToolsJar()) } + +def getRuntimeJar() { + try { + final File javaBase = new File(System.getProperty("java.home")).getCanonicalFile(); + File runtimeJar = new File(javaBase, "lib/rt.jar"); + if (runtimeJar.exists()) { + return runtimeJar; + } + runtimeJar = new File(javaBase, "jre/lib/rt.jar"); + return runtimeJar.exists() ? runtimeJar : null; + } catch (IOException e) { + throw new RuntimeException(e); + } +} From 2d374e6bcde826a1ff7050722a8bda5115ed3854 Mon Sep 17 00:00:00 2001 From: geralt-encore Date: Mon, 6 Feb 2017 11:41:23 +0200 Subject: [PATCH 07/11] Fix lint --- .../src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml b/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml index da125a1a5..a22240fff 100644 --- a/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml +++ b/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml @@ -3,7 +3,7 @@ From cec85da28d6b4e38bba48d735d24d776e253b722 Mon Sep 17 00:00:00 2001 From: Ilya Zorin Date: Mon, 6 Feb 2017 21:07:59 +0200 Subject: [PATCH 08/11] Add java.lang imports to the expected sources --- ...edTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java | 2 +- ...BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java | 2 +- ...BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java | 2 +- .../BoxedTypesFieldsStorIOSQLiteDeleteResolver.java | 2 +- .../BoxedTypesFieldsStorIOSQLiteGetResolver.java | 3 +-- .../BoxedTypesFieldsStorIOSQLitePutResolver.java | 2 +- ...dsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java | 2 +- ...thodsConstructorIgnoreNullStorIOSQLiteGetResolver.java | 8 +++++++- ...thodsConstructorIgnoreNullStorIOSQLitePutResolver.java | 2 +- ...TypesMethodsConstructorStorIOSQLiteDeleteResolver.java | 2 +- ...xedTypesMethodsConstructorStorIOSQLiteGetResolver.java | 8 +++++++- ...xedTypesMethodsConstructorStorIOSQLitePutResolver.java | 2 +- ...FactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java | 2 +- ...odsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java | 8 +++++++- ...odsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java | 2 +- ...pesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java | 2 +- ...dTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java | 8 +++++++- ...dTypesMethodsFactoryMethodStorIOSQLitePutResolver.java | 2 +- .../PrimitiveFieldsStorIOSQLiteDeleteResolver.java | 2 +- .../resources/PrimitiveFieldsStorIOSQLiteGetResolver.java | 2 +- .../resources/PrimitiveFieldsStorIOSQLitePutResolver.java | 2 +- ...itiveMethodsConstructorStorIOSQLiteDeleteResolver.java | 2 +- ...rimitiveMethodsConstructorStorIOSQLiteGetResolver.java | 3 ++- ...rimitiveMethodsConstructorStorIOSQLitePutResolver.java | 2 +- ...iveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java | 2 +- ...mitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java | 3 ++- ...mitiveMethodsFactoryMethodStorIOSQLitePutResolver.java | 2 +- 27 files changed, 53 insertions(+), 28 deletions(-) diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java index e8d429e29..a4b1d6778 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java index bf1c41bd6..02ccf9554 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java @@ -2,8 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java index aaa8534f9..4cf26a560 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java index dd5361533..b2be3f3dc 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java index 274ec28f4..a94ef352f 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java @@ -2,9 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; - +import java.lang.Override; /** * Generated resolver for Get Operation */ diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java index 408c15365..20a1897ed 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java index 024f8a461..e6056cd05 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java index a6957b2fb..e09039295 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java @@ -2,8 +2,14 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java index 177c562fb..a47c4eb6e 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java index efbfa8fc7..1f84d4b08 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java index e44de1380..d638045fe 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java @@ -2,8 +2,14 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java index 7435d73cf..5b42048c1 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java index 583b03d5d..e981180e6 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java index ef333806f..f6db8ed76 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java @@ -2,8 +2,14 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java index 7e0ae6686..dcd94ebb8 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java index 91b9ce298..f567b4e87 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java index 2ce0e1904..509594132 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -2,8 +2,14 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Boolean; +import java.lang.Double; +import java.lang.Float; +import java.lang.Integer; +import java.lang.Long; +import java.lang.Override; +import java.lang.Short; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java index f6c4f45b6..ff08af1e6 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java index 293016281..25ecdcc86 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java index 78173d8ca..5a4c0ef7a 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java @@ -2,8 +2,8 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java index 073f814fd..e1dd9ac80 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java index a6d9c58b9..e6e84558d 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java index 8cf31bf4e..193b91b5b 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java @@ -2,8 +2,9 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; +import java.lang.String; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java index add016786..386d1dfd9 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java index a24ec0b13..32736bd95 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -1,9 +1,9 @@ package com.pushtorefresh.storio.sqlite.annotations; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.delete.DefaultDeleteResolver; import com.pushtorefresh.storio.sqlite.queries.DeleteQuery; +import java.lang.Override; /** * Generated resolver for Delete Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java index 7ebd95a81..131681d64 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -2,8 +2,9 @@ import android.database.Cursor; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; +import java.lang.Override; +import java.lang.String; /** * Generated resolver for Get Operation diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java index 3f42381c5..a0c421ca5 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -2,10 +2,10 @@ import android.content.ContentValues; import android.support.annotation.NonNull; - import com.pushtorefresh.storio.sqlite.operations.put.DefaultPutResolver; import com.pushtorefresh.storio.sqlite.queries.InsertQuery; import com.pushtorefresh.storio.sqlite.queries.UpdateQuery; +import java.lang.Override; /** * Generated resolver for Put Operation From d44c894e723aa214a60c2042c44fa2653408e595 Mon Sep 17 00:00:00 2001 From: geralt-encore Date: Tue, 7 Feb 2017 10:07:48 +0200 Subject: [PATCH 09/11] Fix PR comments --- .../processor/StorIOAnnotationsProcessor.java | 6 +- .../proguard-rules.pro | 17 ---- .../src/main/AndroidManifest.xml | 15 ++-- .../StorIOSQLiteAnnotationsProcessorTest.java | 2 +- .../src/test/resources/BoxedTypesFields.java | 24 ++--- .../resources/BoxedTypesFieldsIgnoreNull.java | 24 ++--- ...ypesFieldsIgnoreNullSQLiteTypeMapping.java | 2 +- ...sIgnoreNullStorIOSQLiteDeleteResolver.java | 6 +- ...eldsIgnoreNullStorIOSQLiteGetResolver.java | 26 +++--- ...eldsIgnoreNullStorIOSQLitePutResolver.java | 30 +++---- .../BoxedTypesFieldsSQLiteTypeMapping.java | 2 +- ...TypesFieldsStorIOSQLiteDeleteResolver.java | 6 +- ...xedTypesFieldsStorIOSQLiteGetResolver.java | 26 +++--- ...xedTypesFieldsStorIOSQLitePutResolver.java | 18 ++-- .../BoxedTypesMethodFactoryMethod.java | 70 +++++++-------- .../BoxedTypesMethodsConstructor.java | 64 ++++++------- ...oxedTypesMethodsConstructorIgnoreNull.java | 64 ++++++------- ...onstructorIgnoreNullSQLiteTypeMapping.java | 2 +- ...rIgnoreNullStorIOSQLiteDeleteResolver.java | 6 +- ...ctorIgnoreNullStorIOSQLiteGetResolver.java | 40 ++++----- ...ctorIgnoreNullStorIOSQLitePutResolver.java | 30 +++---- ...esMethodsConstructorSQLiteTypeMapping.java | 2 +- ...ConstructorStorIOSQLiteDeleteResolver.java | 6 +- ...odsConstructorStorIOSQLiteGetResolver.java | 40 ++++----- ...odsConstructorStorIOSQLitePutResolver.java | 18 ++-- .../BoxedTypesMethodsFactoryMethod.java | 70 +++++++-------- ...edTypesMethodsFactoryMethodIgnoreNull.java | 70 +++++++-------- ...toryMethodIgnoreNullSQLiteTypeMapping.java | 2 +- ...dIgnoreNullStorIOSQLiteDeleteResolver.java | 6 +- ...thodIgnoreNullStorIOSQLiteGetResolver.java | 40 ++++----- ...thodIgnoreNullStorIOSQLitePutResolver.java | 30 +++---- ...MethodsFactoryMethodSQLiteTypeMapping.java | 2 +- ...ctoryMethodStorIOSQLiteDeleteResolver.java | 6 +- ...sFactoryMethodStorIOSQLiteGetResolver.java | 40 ++++----- ...sFactoryMethodStorIOSQLitePutResolver.java | 18 ++-- .../src/test/resources/PrimitiveFields.java | 32 +++---- .../PrimitiveFieldsSQLiteTypeMapping.java | 2 +- ...itiveFieldsStorIOSQLiteDeleteResolver.java | 6 +- ...rimitiveFieldsStorIOSQLiteGetResolver.java | 18 ++-- ...rimitiveFieldsStorIOSQLitePutResolver.java | 22 ++--- .../PrimitiveMethodsConstructor.java | 84 ++++++++--------- ...veMethodsConstructorSQLiteTypeMapping.java | 2 +- ...ConstructorStorIOSQLiteDeleteResolver.java | 6 +- ...odsConstructorStorIOSQLiteGetResolver.java | 20 ++--- ...odsConstructorStorIOSQLitePutResolver.java | 22 ++--- .../PrimitiveMethodsFactoryMethod.java | 90 +++++++++---------- ...MethodsFactoryMethodSQLiteTypeMapping.java | 2 +- ...ctoryMethodStorIOSQLiteDeleteResolver.java | 6 +- ...sFactoryMethodStorIOSQLiteGetResolver.java | 20 ++--- ...sFactoryMethodStorIOSQLitePutResolver.java | 22 ++--- .../generate/DeleteResolverGenerator.java | 2 +- .../generate/GetResolverGenerator.java | 2 +- .../processor/generate/MappingGenerator.java | 2 +- .../generate/PutResolverGenerator.java | 2 +- 54 files changed, 586 insertions(+), 606 deletions(-) delete mode 100644 storio-sqlite-annotations-processor-test/proguard-rules.pro diff --git a/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java b/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java index 4a97e08d4..355c65a99 100644 --- a/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java +++ b/storio-common-annotations-processor/src/main/java/com/pushtorefresh/storio/common/annotations/processor/StorIOAnnotationsProcessor.java @@ -130,11 +130,11 @@ protected void validateAnnotatedFieldOrMethod(@NotNull final Element annotatedEl if (enclosingElement.getAnnotation(getTypeAnnotationClass()) == null) { Element superClass = typeUtils.asElement(((TypeElement) enclosingElement).getSuperclass()); if (superClass.getAnnotation(getTypeAnnotationClass()) != null) { - throw new SkipNotAnnotatedClassWithAnnotatedParentException("Fields of classes not annotated with" + throw new SkipNotAnnotatedClassWithAnnotatedParentException("Fields of classes not annotated with " + getTypeAnnotationClass().getSimpleName() - + "which have parents annotated with" + + " which have parents annotated with " + getTypeAnnotationClass().getSimpleName() - + "will be skipped (e.g. AutoValue case)"); + + " will be skipped (e.g. AutoValue case)"); } else { throw new ProcessingException(annotatedElement, "Please annotate class " diff --git a/storio-sqlite-annotations-processor-test/proguard-rules.pro b/storio-sqlite-annotations-processor-test/proguard-rules.pro deleted file mode 100644 index 955c8824d..000000000 --- a/storio-sqlite-annotations-processor-test/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/ilyazorin/Development/Android/android-sdk-macosx/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml b/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml index a22240fff..3aef525bd 100644 --- a/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml +++ b/storio-sqlite-annotations-processor-test/src/main/AndroidManifest.xml @@ -1,11 +1,8 @@ - - - - - + + diff --git a/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java index ec07d5822..8fe94c34f 100644 --- a/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java +++ b/storio-sqlite-annotations-processor-test/src/test/java/com/pushtorefresh/storio/sqlite/annotations/processor/test/StorIOSQLiteAnnotationsProcessorTest.java @@ -463,4 +463,4 @@ public void shouldCompileWithMethodsReturningBoxedTypesAndMarkedAsIgnoreNullAndF .generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver); } -} \ No newline at end of file +} diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java index 9c87a1369..fda9257fc 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java @@ -3,21 +3,21 @@ @StorIOSQLiteType(table = "table") public class BoxedTypesFields { - @StorIOSQLiteColumn(name = "booleanField") - Boolean booleanField; + @StorIOSQLiteColumn(name = "field1") + Boolean field1; - @StorIOSQLiteColumn(name = "shortField") - Short shortField; + @StorIOSQLiteColumn(name = "field2") + Short field2; - @StorIOSQLiteColumn(name = "intField") - Integer intField; + @StorIOSQLiteColumn(name = "field3") + Integer field3; - @StorIOSQLiteColumn(name = "longField", key = true) - Long longField; + @StorIOSQLiteColumn(name = "field4", key = true) + Long field4; - @StorIOSQLiteColumn(name = "floatField") - Float floatField; + @StorIOSQLiteColumn(name = "field5") + Float field5; - @StorIOSQLiteColumn(name = "doubleField") - Double doubleField; + @StorIOSQLiteColumn(name = "field6") + Double field6; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java index b7c3acc85..5e7e70053 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNull.java @@ -3,21 +3,21 @@ @StorIOSQLiteType(table = "table") public class BoxedTypesFieldsIgnoreNull { - @StorIOSQLiteColumn(name = "booleanField", ignoreNull = true) - Boolean booleanField; + @StorIOSQLiteColumn(name = "field1", ignoreNull = true) + Boolean field1; - @StorIOSQLiteColumn(name = "shortField", ignoreNull = true) - Short shortField; + @StorIOSQLiteColumn(name = "field2", ignoreNull = true) + Short field2; - @StorIOSQLiteColumn(name = "intField", ignoreNull = true) - Integer intField; + @StorIOSQLiteColumn(name = "field3", ignoreNull = true) + Integer field3; - @StorIOSQLiteColumn(name = "longField", key = true, ignoreNull = true) - Long longField; + @StorIOSQLiteColumn(name = "field4", key = true, ignoreNull = true) + Long field4; - @StorIOSQLiteColumn(name = "floatField", ignoreNull = true) - Float floatField; + @StorIOSQLiteColumn(name = "field5", ignoreNull = true) + Float field5; - @StorIOSQLiteColumn(name = "doubleField", ignoreNull = true) - Double doubleField; + @StorIOSQLiteColumn(name = "field6", ignoreNull = true) + Double field6; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java index a553f3c84..3fb13a026 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class BoxedTypesFieldsIgnoreNullSQLiteTypeMapping extends SQLiteTypeMapping { public BoxedTypesFieldsIgnoreNullSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java index a4b1d6778..06a33ca58 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver extends Defaul public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesFieldsIgnoreNull object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.longField) + .where("field4 = ?") + .whereArgs(object.field4) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java index 02ccf9554..e39ad659f 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -17,23 +17,23 @@ public class BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver extends DefaultGe public BoxedTypesFieldsIgnoreNull mapFromCursor(@NonNull Cursor cursor) { BoxedTypesFieldsIgnoreNull object = new BoxedTypesFieldsIgnoreNull(); - if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { - object.floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + if (!cursor.isNull(cursor.getColumnIndex("field1"))) { + object.field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; } - if (!cursor.isNull(cursor.getColumnIndex("longField"))) { - object.longField = cursor.getLong(cursor.getColumnIndex("longField")); + if (!cursor.isNull(cursor.getColumnIndex("field6"))) { + object.field6 = cursor.getDouble(cursor.getColumnIndex("field6")); } - if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { - object.doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + if (!cursor.isNull(cursor.getColumnIndex("field3"))) { + object.field3 = cursor.getInt(cursor.getColumnIndex("field3")); } - if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { - object.booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + if (!cursor.isNull(cursor.getColumnIndex("field2"))) { + object.field2 = cursor.getShort(cursor.getColumnIndex("field2")); } - if (!cursor.isNull(cursor.getColumnIndex("intField"))) { - object.intField = cursor.getInt(cursor.getColumnIndex("intField")); + if (!cursor.isNull(cursor.getColumnIndex("field5"))) { + object.field5 = cursor.getFloat(cursor.getColumnIndex("field5")); } - if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { - object.shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + if (!cursor.isNull(cursor.getColumnIndex("field4"))) { + object.field4 = cursor.getLong(cursor.getColumnIndex("field4")); } return object; diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java index 4cf26a560..5a51d2bfd 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull BoxedTypesFieldsIgnoreNull object) public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesFieldsIgnoreNull object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.longField) + .where("field4 = ?") + .whereArgs(object.field4) .build(); } @@ -43,23 +43,23 @@ public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesFieldsIgnoreNull object) public ContentValues mapToContentValues(@NonNull BoxedTypesFieldsIgnoreNull object) { ContentValues contentValues = new ContentValues(6); - if (object.floatField != null) { - contentValues.put("floatField", object.floatField); + if (object.field1 != null) { + contentValues.put("field1", object.field1); } - if (object.longField != null) { - contentValues.put("longField", object.longField); + if (object.field6 != null) { + contentValues.put("field6", object.field6); } - if (object.doubleField != null) { - contentValues.put("doubleField", object.doubleField); + if (object.field3 != null) { + contentValues.put("field3", object.field3); } - if (object.booleanField != null) { - contentValues.put("booleanField", object.booleanField); + if (object.field2 != null) { + contentValues.put("field2", object.field2); } - if (object.intField != null) { - contentValues.put("intField", object.intField); + if (object.field5 != null) { + contentValues.put("field5", object.field5); } - if (object.shortField != null) { - contentValues.put("shortField", object.shortField); + if (object.field4 != null) { + contentValues.put("field4", object.field4); } return contentValues; diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java index 1519786b5..e33bbbbb6 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class BoxedTypesFieldsSQLiteTypeMapping extends SQLiteTypeMapping { public BoxedTypesFieldsSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java index b2be3f3dc..8b3fce431 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class BoxedTypesFieldsStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class BoxedTypesFieldsStorIOSQLiteDeleteResolver extends DefaultDeleteRes public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesFields object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.longField) + .where("field4 = ?") + .whereArgs(object.field4) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java index a94ef352f..e84049bd1 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLiteGetResolver.java @@ -5,7 +5,7 @@ import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver; import java.lang.Override; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class BoxedTypesFieldsStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -16,23 +16,23 @@ public class BoxedTypesFieldsStorIOSQLiteGetResolver extends DefaultGetResolver< public BoxedTypesFields mapFromCursor(@NonNull Cursor cursor) { BoxedTypesFields object = new BoxedTypesFields(); - if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { - object.floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + if (!cursor.isNull(cursor.getColumnIndex("field1"))) { + object.field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; } - if (!cursor.isNull(cursor.getColumnIndex("longField"))) { - object.longField = cursor.getLong(cursor.getColumnIndex("longField")); + if (!cursor.isNull(cursor.getColumnIndex("field6"))) { + object.field6 = cursor.getDouble(cursor.getColumnIndex("field6")); } - if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { - object.doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + if (!cursor.isNull(cursor.getColumnIndex("field3"))) { + object.field3 = cursor.getInt(cursor.getColumnIndex("field3")); } - if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { - object.booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + if (!cursor.isNull(cursor.getColumnIndex("field2"))) { + object.field2 = cursor.getShort(cursor.getColumnIndex("field2")); } - if (!cursor.isNull(cursor.getColumnIndex("intField"))) { - object.intField = cursor.getInt(cursor.getColumnIndex("intField")); + if (!cursor.isNull(cursor.getColumnIndex("field5"))) { + object.field5 = cursor.getFloat(cursor.getColumnIndex("field5")); } - if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { - object.shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + if (!cursor.isNull(cursor.getColumnIndex("field4"))) { + object.field4 = cursor.getLong(cursor.getColumnIndex("field4")); } return object; diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java index 20a1897ed..3bf0ea4ef 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFieldsStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class BoxedTypesFieldsStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull BoxedTypesFields object) { public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesFields object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.longField) + .where("field4 = ?") + .whereArgs(object.field4) .build(); } @@ -43,12 +43,12 @@ public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesFields object) { public ContentValues mapToContentValues(@NonNull BoxedTypesFields object) { ContentValues contentValues = new ContentValues(6); - contentValues.put("floatField", object.floatField); - contentValues.put("longField", object.longField); - contentValues.put("doubleField", object.doubleField); - contentValues.put("booleanField", object.booleanField); - contentValues.put("intField", object.intField); - contentValues.put("shortField", object.shortField); + contentValues.put("field1", object.field1); + contentValues.put("field6", object.field6); + contentValues.put("field3", object.field3); + contentValues.put("field2", object.field2); + contentValues.put("field5", object.field5); + contentValues.put("field4", object.field4); return contentValues; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java index 0fdd7a4ab..f80b56e4d 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodFactoryMethod.java @@ -3,61 +3,61 @@ @StorIOSQLiteType(table = "table") public class BoxedTypesMethodsFactoryMethod { - private Boolean booleanField; + private Boolean field1; - private Short shortField; + private Short field2; - private Integer intField; + private Integer field3; - private Long longField; + private Long field4; - private Float floatField; + private Float field5; - private Double doubleField; + private Double field6; @StorIOSQLiteCreator - public static BoxedTypesMethodsFactoryMethod create(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, - Double doubleField) { - return new BoxedTypesMethodsFactoryMethod(booleanField, shortField, intField, longField, floatField, doubleField); + public static BoxedTypesMethodsFactoryMethod create(Boolean field1, Short field2, Integer field3, Long field4, Float field5, + Double field6) { + return new BoxedTypesMethodsFactoryMethod(field1, field2, field3, field4, field5, field6); } - private BoxedTypesMethodsFactoryMethod(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, - Double doubleField) { - this.booleanField = booleanField; - this.shortField = shortField; - this.intField = intField; - this.longField = longField; - this.floatField = floatField; - this.doubleField = doubleField; + private BoxedTypesMethodsFactoryMethod(Boolean field1, Short field2, Integer field3, Long field4, Float field5, + Double field6) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + this.field4 = field4; + this.field5 = field5; + this.field6 = field6; } - @StorIOSQLiteColumn(name = "booleanField") - public Boolean isBooleanField() { - return booleanField; + @StorIOSQLiteColumn(name = "field1") + public Boolean getField1() { + return field1; } - @StorIOSQLiteColumn(name = "shortField") - public Short getShortField() { - return shortField; + @StorIOSQLiteColumn(name = "field2") + public Short getField2() { + return field2; } - @StorIOSQLiteColumn(name = "intField") - public Integer getIntField() { - return intField; + @StorIOSQLiteColumn(name = "field3") + public Integer getField3() { + return field3; } - @StorIOSQLiteColumn(name = "longField", key = true) - public Long getLongField() { - return longField; + @StorIOSQLiteColumn(name = "field4", key = true) + public Long getField4() { + return field4; } - @StorIOSQLiteColumn(name = "floatField") - public Float getFloatField() { - return floatField; + @StorIOSQLiteColumn(name = "field5") + public Float getField5() { + return field5; } - @StorIOSQLiteColumn(name = "doubleField") - public Double getDoubleField() { - return doubleField; + @StorIOSQLiteColumn(name = "field6") + public Double getField6() { + return field6; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java index 8259cb8d9..d3548d7a2 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructor.java @@ -3,56 +3,56 @@ @StorIOSQLiteType(table = "table") public class BoxedTypesMethodsConstructor { - private Boolean booleanField; + private Boolean field1; - private Short shortField; + private Short field2; - private Integer intField; + private Integer field3; - private Long longField; + private Long field4; - private Float floatField; + private Float field5; - private Double doubleField; + private Double field6; @StorIOSQLiteCreator - public BoxedTypesMethodsConstructor(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, - Double doubleField) { - this.booleanField = booleanField; - this.shortField = shortField; - this.intField = intField; - this.longField = longField; - this.floatField = floatField; - this.doubleField = doubleField; + public BoxedTypesMethodsConstructor(Boolean field1, Short field2, Integer field3, Long field4, Float field5, + Double field6) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + this.field4 = field4; + this.field5 = field5; + this.field6 = field6; } - @StorIOSQLiteColumn(name = "booleanField") - public Boolean isBooleanField() { - return booleanField; + @StorIOSQLiteColumn(name = "field1") + public Boolean getField1() { + return field1; } - @StorIOSQLiteColumn(name = "shortField") - public Short getShortField() { - return shortField; + @StorIOSQLiteColumn(name = "field2") + public Short getField2() { + return field2; } - @StorIOSQLiteColumn(name = "intField") - public Integer getIntField() { - return intField; + @StorIOSQLiteColumn(name = "field3") + public Integer getField3() { + return field3; } - @StorIOSQLiteColumn(name = "longField", key = true) - public Long getLongField() { - return longField; + @StorIOSQLiteColumn(name = "field4", key = true) + public Long getField4() { + return field4; } - @StorIOSQLiteColumn(name = "floatField") - public Float getFloatField() { - return floatField; + @StorIOSQLiteColumn(name = "field5") + public Float getField5() { + return field5; } - @StorIOSQLiteColumn(name = "doubleField") - public Double getDoubleField() { - return doubleField; + @StorIOSQLiteColumn(name = "field6") + public Double getField6() { + return field6; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java index ccd18d21f..21d6d2f76 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNull.java @@ -3,56 +3,56 @@ @StorIOSQLiteType(table = "table") public class BoxedTypesMethodsConstructorIgnoreNull { - private Boolean booleanField; + private Boolean field1; - private Short shortField; + private Short field2; - private Integer intField; + private Integer field3; - private Long longField; + private Long field4; - private Float floatField; + private Float field5; - private Double doubleField; + private Double field6; @StorIOSQLiteCreator - public BoxedTypesMethodsConstructorIgnoreNull(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, - Double doubleField) { - this.booleanField = booleanField; - this.shortField = shortField; - this.intField = intField; - this.longField = longField; - this.floatField = floatField; - this.doubleField = doubleField; + public BoxedTypesMethodsConstructorIgnoreNull(Boolean field1, Short field2, Integer field3, Long field4, Float field5, + Double field6) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + this.field4 = field4; + this.field5 = field5; + this.field6 = field6; } - @StorIOSQLiteColumn(name = "booleanField", ignoreNull = true) - public Boolean isBooleanField() { - return booleanField; + @StorIOSQLiteColumn(name = "field1", ignoreNull = true) + public Boolean getField1() { + return field1; } - @StorIOSQLiteColumn(name = "shortField", ignoreNull = true) - public Short getShortField() { - return shortField; + @StorIOSQLiteColumn(name = "field2", ignoreNull = true) + public Short getField2() { + return field2; } - @StorIOSQLiteColumn(name = "intField", ignoreNull = true) - public Integer getIntField() { - return intField; + @StorIOSQLiteColumn(name = "field3", ignoreNull = true) + public Integer getField3() { + return field3; } - @StorIOSQLiteColumn(name = "longField", key = true, ignoreNull = true) - public Long getLongField() { - return longField; + @StorIOSQLiteColumn(name = "field4", key = true, ignoreNull = true) + public Long getField4() { + return field4; } - @StorIOSQLiteColumn(name = "floatField", ignoreNull = true) - public Float getFloatField() { - return floatField; + @StorIOSQLiteColumn(name = "field5", ignoreNull = true) + public Float getField5() { + return field5; } - @StorIOSQLiteColumn(name = "doubleField", ignoreNull = true) - public Double getDoubleField() { - return doubleField; + @StorIOSQLiteColumn(name = "field6", ignoreNull = true) + public Double getField6() { + return field6; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java index f68559a34..168ca6dad 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping extends SQLiteTypeMapping { public BoxedTypesMethodsConstructorIgnoreNullSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java index e6056cd05..a02845a2e 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteDeleteResolver ex public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsConstructorIgnoreNull object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java index e09039295..faabf1cda 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver.java @@ -12,7 +12,7 @@ import java.lang.Short; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -22,32 +22,32 @@ public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLiteGetResolver exten @NonNull public BoxedTypesMethodsConstructorIgnoreNull mapFromCursor(@NonNull Cursor cursor) { - Boolean booleanField = null; - if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { - booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + Boolean field1 = null; + if (!cursor.isNull(cursor.getColumnIndex("field1"))) { + field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; } - Short shortField = null; - if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { - shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + Short field2 = null; + if (!cursor.isNull(cursor.getColumnIndex("field2"))) { + field2 = cursor.getShort(cursor.getColumnIndex("field2")); } - Integer intField = null; - if (!cursor.isNull(cursor.getColumnIndex("intField"))) { - intField = cursor.getInt(cursor.getColumnIndex("intField")); + Integer field3 = null; + if (!cursor.isNull(cursor.getColumnIndex("field3"))) { + field3 = cursor.getInt(cursor.getColumnIndex("field3")); } - Long longField = null; - if (!cursor.isNull(cursor.getColumnIndex("longField"))) { - longField = cursor.getLong(cursor.getColumnIndex("longField")); + Long field4 = null; + if (!cursor.isNull(cursor.getColumnIndex("field4"))) { + field4 = cursor.getLong(cursor.getColumnIndex("field4")); } - Float floatField = null; - if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { - floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + Float field5 = null; + if (!cursor.isNull(cursor.getColumnIndex("field5"))) { + field5 = cursor.getFloat(cursor.getColumnIndex("field5")); } - Double doubleField = null; - if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { - doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + Double field6 = null; + if (!cursor.isNull(cursor.getColumnIndex("field6"))) { + field6 = cursor.getDouble(cursor.getColumnIndex("field6")); } - BoxedTypesMethodsConstructorIgnoreNull object = new BoxedTypesMethodsConstructorIgnoreNull(booleanField, shortField, intField, longField, floatField, doubleField); + BoxedTypesMethodsConstructorIgnoreNull object = new BoxedTypesMethodsConstructorIgnoreNull(field1, field2, field3, field4, field5, field6); return object; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java index a47c4eb6e..0a11b10e8 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class BoxedTypesMethodsConstructorIgnoreNullStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsConstructorIgnoreN public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsConstructorIgnoreNull object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } @@ -43,23 +43,23 @@ public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsConstructorIgnoreN public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsConstructorIgnoreNull object) { ContentValues contentValues = new ContentValues(6); - if (object.getFloatField() != null) { - contentValues.put("floatField", object.getFloatField()); + if (object.getField1() != null) { + contentValues.put("field1", object.getField1()); } - if (object.getLongField() != null) { - contentValues.put("longField", object.getLongField()); + if (object.getField6() != null) { + contentValues.put("field6", object.getField6()); } - if (object.getDoubleField() != null) { - contentValues.put("doubleField", object.getDoubleField()); + if (object.getField3() != null) { + contentValues.put("field3", object.getField3()); } - if (object.isBooleanField() != null) { - contentValues.put("booleanField", object.isBooleanField()); + if (object.getField2() != null) { + contentValues.put("field2", object.getField2()); } - if (object.getIntField() != null) { - contentValues.put("intField", object.getIntField()); + if (object.getField5() != null) { + contentValues.put("field5", object.getField5()); } - if (object.getShortField() != null) { - contentValues.put("shortField", object.getShortField()); + if (object.getField4() != null) { + contentValues.put("field4", object.getField4()); } return contentValues; diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java index 4b5e370be..3f2152d79 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class BoxedTypesMethodsConstructorSQLiteTypeMapping extends SQLiteTypeMapping { public BoxedTypesMethodsConstructorSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java index 1f84d4b08..239e86479 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class BoxedTypesMethodsConstructorStorIOSQLiteDeleteResolver extends Defa public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsConstructor object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java index d638045fe..a4163a847 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLiteGetResolver.java @@ -12,7 +12,7 @@ import java.lang.Short; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class BoxedTypesMethodsConstructorStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -22,32 +22,32 @@ public class BoxedTypesMethodsConstructorStorIOSQLiteGetResolver extends Default @NonNull public BoxedTypesMethodsConstructor mapFromCursor(@NonNull Cursor cursor) { - Boolean booleanField = null; - if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { - booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + Boolean field1 = null; + if (!cursor.isNull(cursor.getColumnIndex("field1"))) { + field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; } - Short shortField = null; - if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { - shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + Short field2 = null; + if (!cursor.isNull(cursor.getColumnIndex("field2"))) { + field2 = cursor.getShort(cursor.getColumnIndex("field2")); } - Integer intField = null; - if (!cursor.isNull(cursor.getColumnIndex("intField"))) { - intField = cursor.getInt(cursor.getColumnIndex("intField")); + Integer field3 = null; + if (!cursor.isNull(cursor.getColumnIndex("field3"))) { + field3 = cursor.getInt(cursor.getColumnIndex("field3")); } - Long longField = null; - if (!cursor.isNull(cursor.getColumnIndex("longField"))) { - longField = cursor.getLong(cursor.getColumnIndex("longField")); + Long field4 = null; + if (!cursor.isNull(cursor.getColumnIndex("field4"))) { + field4 = cursor.getLong(cursor.getColumnIndex("field4")); } - Float floatField = null; - if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { - floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + Float field5 = null; + if (!cursor.isNull(cursor.getColumnIndex("field5"))) { + field5 = cursor.getFloat(cursor.getColumnIndex("field5")); } - Double doubleField = null; - if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { - doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + Double field6 = null; + if (!cursor.isNull(cursor.getColumnIndex("field6"))) { + field6 = cursor.getDouble(cursor.getColumnIndex("field6")); } - BoxedTypesMethodsConstructor object = new BoxedTypesMethodsConstructor(booleanField, shortField, intField, longField, floatField, doubleField); + BoxedTypesMethodsConstructor object = new BoxedTypesMethodsConstructor(field1, field2, field3, field4, field5, field6); return object; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java index 5b42048c1..c3e5e2c01 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsConstructorStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class BoxedTypesMethodsConstructorStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsConstructor object public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsConstructor object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } @@ -43,12 +43,12 @@ public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsConstructor object public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsConstructor object) { ContentValues contentValues = new ContentValues(6); - contentValues.put("floatField", object.getFloatField()); - contentValues.put("longField", object.getLongField()); - contentValues.put("doubleField", object.getDoubleField()); - contentValues.put("booleanField", object.isBooleanField()); - contentValues.put("intField", object.getIntField()); - contentValues.put("shortField", object.getShortField()); + contentValues.put("field1", object.getField1()); + contentValues.put("field6", object.getField6()); + contentValues.put("field3", object.getField3()); + contentValues.put("field2", object.getField2()); + contentValues.put("field5", object.getField5()); + contentValues.put("field4", object.getField4()); return contentValues; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java index e06fa5628..aa8bc3577 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethod.java @@ -3,61 +3,61 @@ @StorIOSQLiteType(table = "table") public class BoxedTypesMethodsFactoryMethod { - private Boolean booleanField; + private Boolean field1; - private Short shortField; + private Short field2; - private Integer intField; + private Integer field3; - private Long longField; + private Long field4; - private Float floatField; + private Float field5; - private Double doubleField; + private Double field6; @StorIOSQLiteCreator - public static BoxedTypesMethodsFactoryMethod create(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, - Double doubleField) { - return new BoxedTypesMethodsFactoryMethod(booleanField, shortField, intField, longField, floatField, doubleField); + public static BoxedTypesMethodsFactoryMethod create(Boolean field1, Short field2, Integer field3, Long field4, Float field5, + Double field6) { + return new BoxedTypesMethodsFactoryMethod(field1, field2, field3, field4, field5, field6); } - private BoxedTypesMethodsFactoryMethod(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, - Double doubleField) { - this.booleanField = booleanField; - this.shortField = shortField; - this.intField = intField; - this.longField = longField; - this.floatField = floatField; - this.doubleField = doubleField; + private BoxedTypesMethodsFactoryMethod(Boolean field1, Short field2, Integer field3, Long field4, Float field5, + Double field6) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + this.field4 = field4; + this.field5 = field5; + this.field6 = field6; } - @StorIOSQLiteColumn(name = "booleanField") - public Boolean isBooleanField() { - return booleanField; + @StorIOSQLiteColumn(name = "field1") + public Boolean getField1() { + return field1; } - @StorIOSQLiteColumn(name = "shortField") - public Short getShortField() { - return shortField; + @StorIOSQLiteColumn(name = "field2") + public Short getField2() { + return field2; } - @StorIOSQLiteColumn(name = "intField") - public Integer getIntField() { - return intField; + @StorIOSQLiteColumn(name = "field3") + public Integer getField3() { + return field3; } - @StorIOSQLiteColumn(name = "longField", key = true) - public Long getLongField() { - return longField; + @StorIOSQLiteColumn(name = "field4", key = true) + public Long getField4() { + return field4; } - @StorIOSQLiteColumn(name = "floatField") - public Float getFloatField() { - return floatField; + @StorIOSQLiteColumn(name = "field5") + public Float getField5() { + return field5; } - @StorIOSQLiteColumn(name = "doubleField") - public Double getDoubleField() { - return doubleField; + @StorIOSQLiteColumn(name = "field6") + public Double getField6() { + return field6; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java index 79dc8b150..e75f13a39 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNull.java @@ -3,62 +3,62 @@ @StorIOSQLiteType(table = "table") public class BoxedTypesMethodsFactoryMethodIgnoreNull { - private Boolean booleanField; + private Boolean field1; - private Short shortField; + private Short field2; - private Integer intField; + private Integer field3; - private Long longField; + private Long field4; - private Float floatField; + private Float field5; - private Double doubleField; + private Double field6; @StorIOSQLiteCreator - public static BoxedTypesMethodsFactoryMethodIgnoreNull create(Boolean booleanField, Short shortField, Integer intField, Long longField, - Float floatField, Double doubleField) { - return new BoxedTypesMethodsFactoryMethodIgnoreNull(booleanField, shortField, intField, longField, floatField, doubleField); + public static BoxedTypesMethodsFactoryMethodIgnoreNull create(Boolean field1, Short field2, Integer field3, Long field4, + Float field5, Double field6) { + return new BoxedTypesMethodsFactoryMethodIgnoreNull(field1, field2, field3, field4, field5, field6); } - private BoxedTypesMethodsFactoryMethodIgnoreNull(Boolean booleanField, Short shortField, Integer intField, Long longField, Float floatField, - Double doubleField) { - this.booleanField = booleanField; - this.shortField = shortField; - this.intField = intField; - this.longField = longField; - this.floatField = floatField; - this.doubleField = doubleField; + private BoxedTypesMethodsFactoryMethodIgnoreNull(Boolean field1, Short field2, Integer field3, Long field4, Float field5, + Double field6) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + this.field4 = field4; + this.field5 = field5; + this.field6 = field6; } - @StorIOSQLiteColumn(name = "booleanField", ignoreNull = true) - public Boolean isBooleanField() { - return booleanField; + @StorIOSQLiteColumn(name = "field1", ignoreNull = true) + public Boolean getField1() { + return field1; } - @StorIOSQLiteColumn(name = "shortField", ignoreNull = true) - public Short getShortField() { - return shortField; + @StorIOSQLiteColumn(name = "field2", ignoreNull = true) + public Short getField2() { + return field2; } - @StorIOSQLiteColumn(name = "intField", ignoreNull = true) - public Integer getIntField() { - return intField; + @StorIOSQLiteColumn(name = "field3", ignoreNull = true) + public Integer getField3() { + return field3; } - @StorIOSQLiteColumn(name = "longField", key = true, ignoreNull = true) - public Long getLongField() { - return longField; + @StorIOSQLiteColumn(name = "field4", key = true, ignoreNull = true) + public Long getField4() { + return field4; } - @StorIOSQLiteColumn(name = "floatField", ignoreNull = true) - public Float getFloatField() { - return floatField; + @StorIOSQLiteColumn(name = "field5", ignoreNull = true) + public Float getField5() { + return field5; } - @StorIOSQLiteColumn(name = "doubleField", ignoreNull = true) - public Double getDoubleField() { - return doubleField; + @StorIOSQLiteColumn(name = "field6", ignoreNull = true) + public Double getField6() { + return field6; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java index 1ef21975d..75750d67a 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping extends SQLiteTypeMapping { public BoxedTypesMethodsFactoryMethodIgnoreNullSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java index e981180e6..024bd13b4 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteDeleteResolver public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsFactoryMethodIgnoreNull object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java index f6db8ed76..5833e95dd 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver.java @@ -12,7 +12,7 @@ import java.lang.Short; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -22,32 +22,32 @@ public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLiteGetResolver ext @NonNull public BoxedTypesMethodsFactoryMethodIgnoreNull mapFromCursor(@NonNull Cursor cursor) { - Boolean booleanField = null; - if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { - booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + Boolean field1 = null; + if (!cursor.isNull(cursor.getColumnIndex("field1"))) { + field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; } - Short shortField = null; - if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { - shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + Short field2 = null; + if (!cursor.isNull(cursor.getColumnIndex("field2"))) { + field2 = cursor.getShort(cursor.getColumnIndex("field2")); } - Integer intField = null; - if (!cursor.isNull(cursor.getColumnIndex("intField"))) { - intField = cursor.getInt(cursor.getColumnIndex("intField")); + Integer field3 = null; + if (!cursor.isNull(cursor.getColumnIndex("field3"))) { + field3 = cursor.getInt(cursor.getColumnIndex("field3")); } - Long longField = null; - if (!cursor.isNull(cursor.getColumnIndex("longField"))) { - longField = cursor.getLong(cursor.getColumnIndex("longField")); + Long field4 = null; + if (!cursor.isNull(cursor.getColumnIndex("field4"))) { + field4 = cursor.getLong(cursor.getColumnIndex("field4")); } - Float floatField = null; - if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { - floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + Float field5 = null; + if (!cursor.isNull(cursor.getColumnIndex("field5"))) { + field5 = cursor.getFloat(cursor.getColumnIndex("field5")); } - Double doubleField = null; - if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { - doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + Double field6 = null; + if (!cursor.isNull(cursor.getColumnIndex("field6"))) { + field6 = cursor.getDouble(cursor.getColumnIndex("field6")); } - BoxedTypesMethodsFactoryMethodIgnoreNull object = BoxedTypesMethodsFactoryMethodIgnoreNull.create(booleanField, shortField, intField, longField, floatField, doubleField); + BoxedTypesMethodsFactoryMethodIgnoreNull object = BoxedTypesMethodsFactoryMethodIgnoreNull.create(field1, field2, field3, field4, field5, field6); return object; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java index dcd94ebb8..13fcb7375 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class BoxedTypesMethodsFactoryMethodIgnoreNullStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsFactoryMethodIgnor public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsFactoryMethodIgnoreNull object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } @@ -43,23 +43,23 @@ public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsFactoryMethodIgnor public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsFactoryMethodIgnoreNull object) { ContentValues contentValues = new ContentValues(6); - if (object.getFloatField() != null) { - contentValues.put("floatField", object.getFloatField()); + if (object.getField1() != null) { + contentValues.put("field1", object.getField1()); } - if (object.getLongField() != null) { - contentValues.put("longField", object.getLongField()); + if (object.getField6() != null) { + contentValues.put("field6", object.getField6()); } - if (object.getDoubleField() != null) { - contentValues.put("doubleField", object.getDoubleField()); + if (object.getField3() != null) { + contentValues.put("field3", object.getField3()); } - if (object.isBooleanField() != null) { - contentValues.put("booleanField", object.isBooleanField()); + if (object.getField2() != null) { + contentValues.put("field2", object.getField2()); } - if (object.getIntField() != null) { - contentValues.put("intField", object.getIntField()); + if (object.getField5() != null) { + contentValues.put("field5", object.getField5()); } - if (object.getShortField() != null) { - contentValues.put("shortField", object.getShortField()); + if (object.getField4() != null) { + contentValues.put("field4", object.getField4()); } return contentValues; diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java index 6b3fe054a..806a674c1 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class BoxedTypesMethodsFactoryMethodSQLiteTypeMapping extends SQLiteTypeMapping { public BoxedTypesMethodsFactoryMethodSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java index f567b4e87..068aea61e 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver extends De public DeleteQuery mapToDeleteQuery(@NonNull BoxedTypesMethodsFactoryMethod object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java index 509594132..9345ddb18 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -12,7 +12,7 @@ import java.lang.Short; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -22,32 +22,32 @@ public class BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver extends Defau @NonNull public BoxedTypesMethodsFactoryMethod mapFromCursor(@NonNull Cursor cursor) { - Boolean booleanField = null; - if (!cursor.isNull(cursor.getColumnIndex("booleanField"))) { - booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; + Boolean field1 = null; + if (!cursor.isNull(cursor.getColumnIndex("field1"))) { + field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; } - Short shortField = null; - if (!cursor.isNull(cursor.getColumnIndex("shortField"))) { - shortField = cursor.getShort(cursor.getColumnIndex("shortField")); + Short field2 = null; + if (!cursor.isNull(cursor.getColumnIndex("field2"))) { + field2 = cursor.getShort(cursor.getColumnIndex("field2")); } - Integer intField = null; - if (!cursor.isNull(cursor.getColumnIndex("intField"))) { - intField = cursor.getInt(cursor.getColumnIndex("intField")); + Integer field3 = null; + if (!cursor.isNull(cursor.getColumnIndex("field3"))) { + field3 = cursor.getInt(cursor.getColumnIndex("field3")); } - Long longField = null; - if (!cursor.isNull(cursor.getColumnIndex("longField"))) { - longField = cursor.getLong(cursor.getColumnIndex("longField")); + Long field4 = null; + if (!cursor.isNull(cursor.getColumnIndex("field4"))) { + field4 = cursor.getLong(cursor.getColumnIndex("field4")); } - Float floatField = null; - if (!cursor.isNull(cursor.getColumnIndex("floatField"))) { - floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); + Float field5 = null; + if (!cursor.isNull(cursor.getColumnIndex("field5"))) { + field5 = cursor.getFloat(cursor.getColumnIndex("field5")); } - Double doubleField = null; - if (!cursor.isNull(cursor.getColumnIndex("doubleField"))) { - doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); + Double field6 = null; + if (!cursor.isNull(cursor.getColumnIndex("field6"))) { + field6 = cursor.getDouble(cursor.getColumnIndex("field6")); } - BoxedTypesMethodsFactoryMethod object = BoxedTypesMethodsFactoryMethod.create(booleanField, shortField, intField, longField, floatField, doubleField); + BoxedTypesMethodsFactoryMethod object = BoxedTypesMethodsFactoryMethod.create(field1, field2, field3, field4, field5, field6); return object; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java index ff08af1e6..d6d2b9e6f 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull BoxedTypesMethodsFactoryMethod obje public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsFactoryMethod object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } @@ -43,12 +43,12 @@ public UpdateQuery mapToUpdateQuery(@NonNull BoxedTypesMethodsFactoryMethod obje public ContentValues mapToContentValues(@NonNull BoxedTypesMethodsFactoryMethod object) { ContentValues contentValues = new ContentValues(6); - contentValues.put("floatField", object.getFloatField()); - contentValues.put("longField", object.getLongField()); - contentValues.put("doubleField", object.getDoubleField()); - contentValues.put("booleanField", object.isBooleanField()); - contentValues.put("intField", object.getIntField()); - contentValues.put("shortField", object.getShortField()); + contentValues.put("field1", object.getField1()); + contentValues.put("field6", object.getField6()); + contentValues.put("field3", object.getField3()); + contentValues.put("field2", object.getField2()); + contentValues.put("field5", object.getField5()); + contentValues.put("field4", object.getField4()); return contentValues; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java index 3d524bd4d..8125b6979 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFields.java @@ -3,27 +3,27 @@ @StorIOSQLiteType(table = "table") public class PrimitiveFields { - @StorIOSQLiteColumn(name = "booleanField") - boolean booleanField; + @StorIOSQLiteColumn(name = "field1") + boolean field1; - @StorIOSQLiteColumn(name = "shortField") - short shortField; + @StorIOSQLiteColumn(name = "field2") + short field2; - @StorIOSQLiteColumn(name = "intField") - int intField; + @StorIOSQLiteColumn(name = "field3") + int field3; - @StorIOSQLiteColumn(name = "longField", key = true) - long longField; + @StorIOSQLiteColumn(name = "field4", key = true) + long field4; - @StorIOSQLiteColumn(name = "floatField") - float floatField; + @StorIOSQLiteColumn(name = "field5") + float field5; - @StorIOSQLiteColumn(name = "doubleField") - double doubleField; + @StorIOSQLiteColumn(name = "field6") + double field6; - @StorIOSQLiteColumn(name = "stringField") - String stringField; + @StorIOSQLiteColumn(name = "field7") + String field7; - @StorIOSQLiteColumn(name = "byteArrayField") - byte[] byteArrayField; + @StorIOSQLiteColumn(name = "field8") + byte[] field8; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java index 9d3b9c014..8fa178039 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class PrimitiveFieldsSQLiteTypeMapping extends SQLiteTypeMapping { public PrimitiveFieldsSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java index 25ecdcc86..4527bd786 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class PrimitiveFieldsStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class PrimitiveFieldsStorIOSQLiteDeleteResolver extends DefaultDeleteReso public DeleteQuery mapToDeleteQuery(@NonNull PrimitiveFields object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.longField) + .where("field4 = ?") + .whereArgs(object.field4) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java index 5a4c0ef7a..2e59db414 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveFieldsStorIOSQLiteGetResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class PrimitiveFieldsStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -17,14 +17,14 @@ public class PrimitiveFieldsStorIOSQLiteGetResolver extends DefaultGetResolver

{ /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull PrimitiveFields object) { public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveFields object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.longField) + .where("field4 = ?") + .whereArgs(object.field4) .build(); } @@ -43,14 +43,14 @@ public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveFields object) { public ContentValues mapToContentValues(@NonNull PrimitiveFields object) { ContentValues contentValues = new ContentValues(8); - contentValues.put("floatField", object.floatField); - contentValues.put("longField", object.longField); - contentValues.put("doubleField", object.doubleField); - contentValues.put("booleanField", object.booleanField); - contentValues.put("intField", object.intField); - contentValues.put("stringField", object.stringField); - contentValues.put("shortField", object.shortField); - contentValues.put("byteArrayField", object.byteArrayField); + contentValues.put("field1", object.field1); + contentValues.put("field7", object.field7); + contentValues.put("field6", object.field6); + contentValues.put("field8", object.field8); + contentValues.put("field3", object.field3); + contentValues.put("field2", object.field2); + contentValues.put("field5", object.field5); + contentValues.put("field4", object.field4); return contentValues; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java index 0cbb0537e..efe1cd172 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructor.java @@ -3,72 +3,72 @@ @StorIOSQLiteType(table = "table") public class PrimitiveMethodsConstructor { - private boolean booleanField; + private boolean field1; - private short shortField; + private short field2; - private int intField; + private int field3; - private long longField; + private long field4; - private float floatField; + private float field5; - private double doubleField; + private double field6; - private String stringField; + private String field7; - private byte[] byteArrayField; + private byte[] field8; @StorIOSQLiteCreator - public PrimitiveMethodsConstructor(boolean booleanField, short shortField, int intField, long longField, float floatField, - double doubleField, String stringField, byte[] byteArrayField) { - this.booleanField = booleanField; - this.shortField = shortField; - this.intField = intField; - this.longField = longField; - this.floatField = floatField; - this.doubleField = doubleField; - this.stringField = stringField; - this.byteArrayField = byteArrayField; + public PrimitiveMethodsConstructor(boolean field1, short field2, int field3, long field4, float field5, + double field6, String field7, byte[] field8) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + this.field4 = field4; + this.field5 = field5; + this.field6 = field6; + this.field7 = field7; + this.field8 = field8; } - @StorIOSQLiteColumn(name = "booleanField") - public boolean isBooleanField() { - return booleanField; + @StorIOSQLiteColumn(name = "field1") + public boolean getField1() { + return field1; } - @StorIOSQLiteColumn(name = "shortField") - public short getShortField() { - return shortField; + @StorIOSQLiteColumn(name = "field2") + public short getField2() { + return field2; } - @StorIOSQLiteColumn(name = "intField") - public int getIntField() { - return intField; + @StorIOSQLiteColumn(name = "field3") + public int getField3() { + return field3; } - @StorIOSQLiteColumn(name = "longField", key = true) - public long getLongField() { - return longField; + @StorIOSQLiteColumn(name = "field4", key = true) + public long getField4() { + return field4; } - @StorIOSQLiteColumn(name = "floatField") - public float getFloatField() { - return floatField; + @StorIOSQLiteColumn(name = "field5") + public float getField5() { + return field5; } - @StorIOSQLiteColumn(name = "doubleField") - public double getDoubleField() { - return doubleField; + @StorIOSQLiteColumn(name = "field6") + public double getField6() { + return field6; } - @StorIOSQLiteColumn(name = "stringField") - public String getStringField() { - return stringField; + @StorIOSQLiteColumn(name = "field7") + public String getField7() { + return field7; } - @StorIOSQLiteColumn(name = "byteArrayField") - public byte[] getByteArrayField() { - return byteArrayField; + @StorIOSQLiteColumn(name = "field8") + public byte[] getField8() { + return field8; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java index 388fbc27f..d23bf0fa9 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class PrimitiveMethodsConstructorSQLiteTypeMapping extends SQLiteTypeMapping { public PrimitiveMethodsConstructorSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java index e6e84558d..588d7aa00 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver extends Defau public DeleteQuery mapToDeleteQuery(@NonNull PrimitiveMethodsConstructor object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java index 193b91b5b..361cfc6c8 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java @@ -7,7 +7,7 @@ import java.lang.String; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class PrimitiveMethodsConstructorStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -17,16 +17,16 @@ public class PrimitiveMethodsConstructorStorIOSQLiteGetResolver extends DefaultG @NonNull public PrimitiveMethodsConstructor mapFromCursor(@NonNull Cursor cursor) { - boolean booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; - short shortField = cursor.getShort(cursor.getColumnIndex("shortField")); - int intField = cursor.getInt(cursor.getColumnIndex("intField")); - long longField = cursor.getLong(cursor.getColumnIndex("longField")); - float floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); - double doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); - String stringField = cursor.getString(cursor.getColumnIndex("stringField")); - byte[] byteArrayField = cursor.getBlob(cursor.getColumnIndex("byteArrayField")); + boolean field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; + short field2 = cursor.getShort(cursor.getColumnIndex("field2")); + int field3 = cursor.getInt(cursor.getColumnIndex("field3")); + long field4 = cursor.getLong(cursor.getColumnIndex("field4")); + float field5 = cursor.getFloat(cursor.getColumnIndex("field5")); + double field6 = cursor.getDouble(cursor.getColumnIndex("field6")); + String field7 = cursor.getString(cursor.getColumnIndex("field7")); + byte[] field8 = cursor.getBlob(cursor.getColumnIndex("field8")); - PrimitiveMethodsConstructor object = new PrimitiveMethodsConstructor(booleanField, shortField, intField, longField, floatField, doubleField, stringField, byteArrayField); + PrimitiveMethodsConstructor object = new PrimitiveMethodsConstructor(field1, field2, field3, field4, field5, field6, field7, field8); return object; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java index 386d1dfd9..0854a9fc9 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsConstructorStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class PrimitiveMethodsConstructorStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull PrimitiveMethodsConstructor object) public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveMethodsConstructor object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } @@ -43,14 +43,14 @@ public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveMethodsConstructor object) public ContentValues mapToContentValues(@NonNull PrimitiveMethodsConstructor object) { ContentValues contentValues = new ContentValues(8); - contentValues.put("floatField", object.getFloatField()); - contentValues.put("longField", object.getLongField()); - contentValues.put("doubleField", object.getDoubleField()); - contentValues.put("booleanField", object.isBooleanField()); - contentValues.put("intField", object.getIntField()); - contentValues.put("stringField", object.getStringField()); - contentValues.put("shortField", object.getShortField()); - contentValues.put("byteArrayField", object.getByteArrayField()); + contentValues.put("field1", object.getField1()); + contentValues.put("field7", object.getField7()); + contentValues.put("field6", object.getField6()); + contentValues.put("field8", object.getField8()); + contentValues.put("field3", object.getField3()); + contentValues.put("field2", object.getField2()); + contentValues.put("field5", object.getField5()); + contentValues.put("field4", object.getField4()); return contentValues; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java index 7650f6839..78e263449 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethod.java @@ -3,77 +3,77 @@ @StorIOSQLiteType(table = "table") public class PrimitiveMethodsFactoryMethod { - private boolean booleanField; + private boolean field1; - private short shortField; + private short field2; - private int intField; + private int field3; - private long longField; + private long field4; - private float floatField; + private float field5; - private double doubleField; + private double field6; - private String stringField; + private String field7; - private byte[] byteArrayField; + private byte[] field8; @StorIOSQLiteCreator - public static PrimitiveMethodsFactoryMethod create(boolean booleanField, short shortField, int intField, long longField, float floatField, - double doubleField, String stringField, byte[] byteArrayField) { - return new PrimitiveMethodsFactoryMethod(booleanField, shortField, intField, longField, floatField, doubleField, stringField, byteArrayField); + public static PrimitiveMethodsFactoryMethod create(boolean field1, short field2, int field3, long field4, float field5, + double field6, String field7, byte[] field8) { + return new PrimitiveMethodsFactoryMethod(field1, field2, field3, field4, field5, field6, field7, field8); } - private PrimitiveMethodsFactoryMethod(boolean booleanField, short shortField, int intField, long longField, float floatField, - double doubleField, String stringField, byte[] byteArrayField) { - this.booleanField = booleanField; - this.shortField = shortField; - this.intField = intField; - this.longField = longField; - this.floatField = floatField; - this.doubleField = doubleField; - this.stringField = stringField; - this.byteArrayField = byteArrayField; + private PrimitiveMethodsFactoryMethod(boolean field1, short field2, int field3, long field4, float field5, + double field6, String field7, byte[] field8) { + this.field1 = field1; + this.field2 = field2; + this.field3 = field3; + this.field4 = field4; + this.field5 = field5; + this.field6 = field6; + this.field7 = field7; + this.field8 = field8; } - @StorIOSQLiteColumn(name = "booleanField") - public boolean isBooleanField() { - return booleanField; + @StorIOSQLiteColumn(name = "field1") + public boolean getField1() { + return field1; } - @StorIOSQLiteColumn(name = "shortField") - public short getShortField() { - return shortField; + @StorIOSQLiteColumn(name = "field2") + public short getField2() { + return field2; } - @StorIOSQLiteColumn(name = "intField") - public int getIntField() { - return intField; + @StorIOSQLiteColumn(name = "field3") + public int getField3() { + return field3; } - @StorIOSQLiteColumn(name = "longField", key = true) - public long getLongField() { - return longField; + @StorIOSQLiteColumn(name = "field4", key = true) + public long getField4() { + return field4; } - @StorIOSQLiteColumn(name = "floatField") - public float getFloatField() { - return floatField; + @StorIOSQLiteColumn(name = "field5") + public float getField5() { + return field5; } - @StorIOSQLiteColumn(name = "doubleField") - public double getDoubleField() { - return doubleField; + @StorIOSQLiteColumn(name = "field6") + public double getField6() { + return field6; } - @StorIOSQLiteColumn(name = "stringField") - public String getStringField() { - return stringField; + @StorIOSQLiteColumn(name = "field7") + public String getField7() { + return field7; } - @StorIOSQLiteColumn(name = "byteArrayField") - public byte[] getByteArrayField() { - return byteArrayField; + @StorIOSQLiteColumn(name = "field8") + public byte[] getField8() { + return field8; } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java index d274364e9..6668c18bc 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodSQLiteTypeMapping.java @@ -3,7 +3,7 @@ import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; /** - * Generated mapping with collection of resolvers + * Generated mapping with collection of resolvers. */ public class PrimitiveMethodsFactoryMethodSQLiteTypeMapping extends SQLiteTypeMapping { public PrimitiveMethodsFactoryMethodSQLiteTypeMapping() { diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java index 32736bd95..2236d5296 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver.java @@ -6,7 +6,7 @@ import java.lang.Override; /** - * Generated resolver for Delete Operation + * Generated resolver for Delete Operation. */ public class PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver extends DefaultDeleteResolver { /** @@ -17,8 +17,8 @@ public class PrimitiveMethodsFactoryMethodStorIOSQLiteDeleteResolver extends Def public DeleteQuery mapToDeleteQuery(@NonNull PrimitiveMethodsFactoryMethod object) { return DeleteQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java index 131681d64..688ea48d7 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver.java @@ -7,7 +7,7 @@ import java.lang.String; /** - * Generated resolver for Get Operation + * Generated resolver for Get Operation. */ public class PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver extends DefaultGetResolver { /** @@ -17,16 +17,16 @@ public class PrimitiveMethodsFactoryMethodStorIOSQLiteGetResolver extends Defaul @NonNull public PrimitiveMethodsFactoryMethod mapFromCursor(@NonNull Cursor cursor) { - boolean booleanField = cursor.getInt(cursor.getColumnIndex("booleanField")) == 1; - short shortField = cursor.getShort(cursor.getColumnIndex("shortField")); - int intField = cursor.getInt(cursor.getColumnIndex("intField")); - long longField = cursor.getLong(cursor.getColumnIndex("longField")); - float floatField = cursor.getFloat(cursor.getColumnIndex("floatField")); - double doubleField = cursor.getDouble(cursor.getColumnIndex("doubleField")); - String stringField = cursor.getString(cursor.getColumnIndex("stringField")); - byte[] byteArrayField = cursor.getBlob(cursor.getColumnIndex("byteArrayField")); + boolean field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1; + short field2 = cursor.getShort(cursor.getColumnIndex("field2")); + int field3 = cursor.getInt(cursor.getColumnIndex("field3")); + long field4 = cursor.getLong(cursor.getColumnIndex("field4")); + float field5 = cursor.getFloat(cursor.getColumnIndex("field5")); + double field6 = cursor.getDouble(cursor.getColumnIndex("field6")); + String field7 = cursor.getString(cursor.getColumnIndex("field7")); + byte[] field8 = cursor.getBlob(cursor.getColumnIndex("field8")); - PrimitiveMethodsFactoryMethod object = PrimitiveMethodsFactoryMethod.create(booleanField, shortField, intField, longField, floatField, doubleField, stringField, byteArrayField); + PrimitiveMethodsFactoryMethod object = PrimitiveMethodsFactoryMethod.create(field1, field2, field3, field4, field5, field6, field7, field8); return object; } diff --git a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java index a0c421ca5..d4bcfdbe4 100644 --- a/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java +++ b/storio-sqlite-annotations-processor-test/src/test/resources/PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver.java @@ -8,7 +8,7 @@ import java.lang.Override; /** - * Generated resolver for Put Operation + * Generated resolver for Put Operation. */ public class PrimitiveMethodsFactoryMethodStorIOSQLitePutResolver extends DefaultPutResolver { /** @@ -30,8 +30,8 @@ public InsertQuery mapToInsertQuery(@NonNull PrimitiveMethodsFactoryMethod objec public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveMethodsFactoryMethod object) { return UpdateQuery.builder() .table("table") - .where("longField = ?") - .whereArgs(object.getLongField()) + .where("field4 = ?") + .whereArgs(object.getField4()) .build(); } @@ -43,14 +43,14 @@ public UpdateQuery mapToUpdateQuery(@NonNull PrimitiveMethodsFactoryMethod objec public ContentValues mapToContentValues(@NonNull PrimitiveMethodsFactoryMethod object) { ContentValues contentValues = new ContentValues(8); - contentValues.put("floatField", object.getFloatField()); - contentValues.put("longField", object.getLongField()); - contentValues.put("doubleField", object.getDoubleField()); - contentValues.put("booleanField", object.isBooleanField()); - contentValues.put("intField", object.getIntField()); - contentValues.put("stringField", object.getStringField()); - contentValues.put("shortField", object.getShortField()); - contentValues.put("byteArrayField", object.getByteArrayField()); + contentValues.put("field1", object.getField1()); + contentValues.put("field7", object.getField7()); + contentValues.put("field6", object.getField6()); + contentValues.put("field8", object.getField8()); + contentValues.put("field3", object.getField3()); + contentValues.put("field2", object.getField2()); + contentValues.put("field5", object.getField5()); + contentValues.put("field4", object.getField4()); return contentValues; } diff --git a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGenerator.java b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGenerator.java index 3b0891acc..ff6cf00c7 100644 --- a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGenerator.java +++ b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/DeleteResolverGenerator.java @@ -31,7 +31,7 @@ public JavaFile generateJavaFile(@NotNull StorIOSQLiteTypeMeta storIOSQLiteTypeM final ClassName storIOSQLiteTypeClassName = ClassName.get(storIOSQLiteTypeMeta.packageName, storIOSQLiteTypeMeta.simpleName); final TypeSpec deleteResolver = TypeSpec.classBuilder(generateName(storIOSQLiteTypeMeta)) - .addJavadoc("Generated resolver for Delete Operation\n") + .addJavadoc("Generated resolver for Delete Operation.\n") .addModifiers(PUBLIC) .superclass(ParameterizedTypeName.get(ClassName.get("com.pushtorefresh.storio.sqlite.operations.delete", "DefaultDeleteResolver"), storIOSQLiteTypeClassName)) .addMethod(createMapToDeleteQueryMethodSpec(storIOSQLiteTypeMeta, storIOSQLiteTypeClassName)) diff --git a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGenerator.java b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGenerator.java index bc6ac2892..04eb84745 100644 --- a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGenerator.java +++ b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/GetResolverGenerator.java @@ -36,7 +36,7 @@ public JavaFile generateJavaFile(@NotNull StorIOSQLiteTypeMeta storIOSQLiteTypeM final ClassName storIOSQLiteTypeClassName = ClassName.get(storIOSQLiteTypeMeta.packageName, storIOSQLiteTypeMeta.simpleName); final TypeSpec getResolver = TypeSpec.classBuilder(generateName(storIOSQLiteTypeMeta)) - .addJavadoc("Generated resolver for Get Operation\n") + .addJavadoc("Generated resolver for Get Operation.\n") .addModifiers(PUBLIC) .superclass(ParameterizedTypeName.get(ClassName.get("com.pushtorefresh.storio.sqlite.operations.get", "DefaultGetResolver"), storIOSQLiteTypeClassName)) .addMethod(storIOSQLiteTypeMeta.needCreator ? createMapFromCursorWithCreatorMethodSpec(storIOSQLiteTypeMeta, storIOSQLiteTypeClassName) diff --git a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGenerator.java b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGenerator.java index 72372aa64..1e6f685da 100644 --- a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGenerator.java +++ b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/MappingGenerator.java @@ -29,7 +29,7 @@ public JavaFile generateJavaFile(@NotNull StorIOSQLiteTypeMeta storIOSQLiteTypeM final TypeSpec mapping = TypeSpec.classBuilder(storIOSQLiteTypeMeta.simpleName + SUFFIX) - .addJavadoc("Generated mapping with collection of resolvers\n") + .addJavadoc("Generated mapping with collection of resolvers.\n") .addModifiers(PUBLIC) .superclass(superclassParametrized) .addMethod(createConstructor(storIOSQLiteTypeMeta)) diff --git a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGenerator.java b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGenerator.java index d462da9d7..60bdff855 100644 --- a/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGenerator.java +++ b/storio-sqlite-annotations-processor/src/main/java/com/pushtorefresh/storio/sqlite/annotations/processor/generate/PutResolverGenerator.java @@ -32,7 +32,7 @@ public JavaFile generateJavaFile(@NotNull StorIOSQLiteTypeMeta storIOSQLiteTypeM final ClassName storIOSQLiteTypeClassName = ClassName.get(storIOSQLiteTypeMeta.packageName, storIOSQLiteTypeMeta.simpleName); final TypeSpec putResolver = TypeSpec.classBuilder(generateName(storIOSQLiteTypeMeta)) - .addJavadoc("Generated resolver for Put Operation\n") + .addJavadoc("Generated resolver for Put Operation.\n") .addModifiers(PUBLIC) .superclass(ParameterizedTypeName.get(ClassName.get("com.pushtorefresh.storio.sqlite.operations.put", "DefaultPutResolver"), storIOSQLiteTypeClassName)) .addMethod(createMapToInsertQueryMethodSpec(storIOSQLiteTypeMeta, storIOSQLiteTypeClassName)) From 1f81c4beb70f1b454fda70a4af486f3f84c54583 Mon Sep 17 00:00:00 2001 From: Ilya Zorin Date: Sun, 12 Feb 2017 23:47:39 +0200 Subject: [PATCH 10/11] CI fix --- ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 3bbf1bad2..5a49aab6f 100644 --- a/ci.sh +++ b/ci.sh @@ -1,3 +1,3 @@ #!/bin/bash # Please run it from root project directory -./gradlew clean build checkstyle -PdisablePreDex +./gradlew clean build checkstyle -PdisablePreDex -x :storio-sqlite-annotations-processor-test:test && ./gradlew :storio-sqlite-annotations-processor-test:testDebugUnitTest From 83f469304c4309d86bc83d8615504c9509c91cdf Mon Sep 17 00:00:00 2001 From: geralt-encore Date: Mon, 13 Feb 2017 09:30:15 +0200 Subject: [PATCH 11/11] Add comment for CI workaround --- ci.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci.sh b/ci.sh index 5a49aab6f..df4a7f15c 100644 --- a/ci.sh +++ b/ci.sh @@ -1,3 +1,5 @@ #!/bin/bash # Please run it from root project directory +# For some reason test for annotation processor are failing on a regular CI setup. +# So we had to exclude test task for it from the main build process and execute it as a separate command. ./gradlew clean build checkstyle -PdisablePreDex -x :storio-sqlite-annotations-processor-test:test && ./gradlew :storio-sqlite-annotations-processor-test:testDebugUnitTest