-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile testing for StorIOSQLiteAnnotationsProcessor #760
Compile testing for StorIOSQLiteAnnotationsProcessor #760
Conversation
Omg, this looks huge, but I wanted to see it in StorIO for a long time,
will take some time to review!
…On Sun, Feb 5, 2017, 19:14 Ilya Zorin ***@***.***> wrote:
@geralt-encore <https://github.com/geralt-encore> requested your review
on: pushtorefresh/storio#760
<#760> Compile testing for
StorIOSQLiteAnnotationsProcessor.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#760 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA7B3JCi0_Jo97_sJfZtlBV1aD91LrtBks5rZfVUgaJpZM4L3ifG>
.
|
It's mostly just resources for assertions. Tests itself are quite small. Also, I've done a couple of changes based on results of tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
org.gradle.internal.jvm.Jvm.current().getRuntimeJar()
was removed =( https://github.com/bfarka/sonar-gradle/blob/295c365f459cd19617b4fe8ce62bdb58b999bd74/src/main/java/org/sonarqube/gradle/SonarQubePlugin.java#L370
https://groups.google.com/forum/#!topic/sonarqube/DnE1npMpaiA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work, @geralt-encore !
Tests look so straightforward without that terrible amount of mocks!
@@ -86,10 +88,19 @@ 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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed spaces around name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luckily it's just a warning message, but I'll fix it anyway. Thanks!
throw new ProcessingException( | ||
classElement, | ||
"Table name of " + classElement.getQualifiedName() + " annotated with " + StorIOSQLiteType.class.getSimpleName() + " is null or empty" | ||
if (tableName.length() == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@nikitin-da but how it can be related to SonarQube? We are not using it, right? |
ButterKnife uses workaround for this https://github.com/JakeWharton/butterknife/blob/7c39e473efd501269a444f2e3d03184eb41d2d05/butterknife/build.gradle#L41 |
At least tests are running now 😐 |
Also, weird thing - after switching to using this workaround java.lang imports appear in generated code. Can't get what is the connection between this two tho. And still don't have any ideas why resources folder isn't picked up by CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small things, otherwise looks great!
@@ -0,0 +1,17 @@ | |||
# Add project specific ProGuard rules here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems unneeded
<application android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="false" | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/>
?
@StorIOSQLiteType(table = "table") | ||
public class BoxedTypesFields { | ||
|
||
@StorIOSQLiteColumn(name = "booleanField") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to make field and column names different so it would not looks like they have to be the same for other contributors/readers of the code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in same places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fieldN would be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just use underscores _
instead of camelCase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean boolean_field
? But what the difference?
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping; | ||
|
||
/** | ||
* Generated mapping with collection of resolvers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And below
contentValues.put("doubleField", object.getDoubleField()); | ||
} | ||
if (object.isBooleanField() != null) { | ||
contentValues.put("booleanField", object.isBooleanField()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, IDE tricked you here with method name 😸
@artem-zinnatullin @nikitin-da I would really appreciate some help in fixing tests in CI. I ran out of ideas for now 😔 |
Interesting, so what I've found so far is that if I run precise task on my laptop Moreover, if I run Moremoremoreover, if I run So I think it's a bug either in Android Gradle Plugin or in Gradle itself. What we can do for now is manually specify how to build it in |
Nice finding! 👍 I'll fix all the comments tomorrow then and then we will be able to merge it. |
I mean I don't want someone to think that names of fields and columns must
be same or follow some pattern, leaving it up to you :)
…On Tue, Feb 7, 2017, 00:25 Ilya Zorin ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
storio-sqlite-annotations-processor-test/src/test/resources/BoxedTypesFields.java
<#760>:
> @@ -0,0 +1,23 @@
+package com.pushtorefresh.storio.sqlite.annotations;
+
***@***.***(table = "table")
+public class BoxedTypesFields {
+
+ @StorIOSQLiteColumn(name = "booleanField")
You mean boolean_field? But what the difference?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#760>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA7B3KYSqKi9GGNcelkXv-5SWEHgkswtks5rZ4_egaJpZM4L3ifG>
.
|
@artem-zinnatullin any updates on this one? |
Waiting for CI fix from you :) |
Sorry, totally forgot about it =( |
Codecov Report
@@ Coverage Diff @@
## master #760 +/- ##
=======================================
Coverage 96.05% 96.05%
=======================================
Files 87 87
Lines 2460 2460
Branches 267 267
=======================================
Hits 2363 2363
Misses 68 68
Partials 29 29 Continue to review full report at Codecov.
|
🎉 |
ci.sh
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment explaining why is this needed :D
While I was working on annotation processor I realised how lacking of proper tests for it made any changes painful to introduce. I set up Compile Testings which works like a charm for purpose of testing of annotation processors. I tried to cover every case that we have atm (both error and regular). Also, I removed some of the previous tests since they have become redundant and it doesn't make sense to maintain them.
Feel free to ask me any questions about it!
I am planning to implement tests in the same fashion for content resolver annotations processor later.