-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simionescu Laurentiu
committed
Jan 28, 2018
1 parent
058fc1a
commit 192c73b
Showing
23 changed files
with
881 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 26 | ||
defaultConfig { | ||
applicationId "com.laurentiusimionescu.validator" | ||
minSdkVersion 21 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:26.1.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.1' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | ||
|
||
compile project(':validator') | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest package="com.laurentiusimionescu.validator"/> |
121 changes: 121 additions & 0 deletions
121
app/src/test/java/com/laurentiusimionescu/validator/ValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package com.laurentiusimionescu.validator; | ||
|
||
import org.junit.Test; | ||
|
||
import static junit.framework.Assert.assertFalse; | ||
import static junit.framework.Assert.assertTrue; | ||
|
||
public class ValidatorTest { | ||
|
||
@Test | ||
public void testNullString() { | ||
|
||
Example example = new Example(); | ||
|
||
assertFalse(ValidationProcessor.isValid(example)); | ||
} | ||
|
||
@Test | ||
public void testEmptyString() { | ||
|
||
Example example = new Example(); | ||
|
||
assertFalse(ValidationProcessor.isValid(example)); | ||
} | ||
|
||
|
||
@Test | ||
public void testAllGood() { | ||
Example example = new Example(); | ||
example.dog = "Dog"; | ||
example.boo = 12; | ||
example.innerClass = new InnerClass(); | ||
example.innerClass.innerString = "i1"; | ||
|
||
example.innerClass3 = new InnerClass(); | ||
example.innerClass3.innerString = "i3"; | ||
|
||
example.castClass = new CastClass(); | ||
example.castClass.castClass = new CastClass(); | ||
|
||
|
||
assertTrue(ValidationProcessor.getMessage(example), ValidationProcessor.isValid(example)); | ||
|
||
} | ||
|
||
@Test | ||
public void testInteger() { | ||
Example example = new Example(); | ||
|
||
|
||
assertFalse(ValidationProcessor.isValid(example)); | ||
|
||
} | ||
|
||
@Test | ||
public void testDouble() { | ||
Example example = new Example(); | ||
|
||
assertFalse(ValidationProcessor.isValid(example)); | ||
|
||
} | ||
|
||
|
||
public class Example { | ||
|
||
@ParamRequired | ||
String dog; | ||
|
||
@ParamOptional(rule = ValidatorRule.EMAIL) | ||
String email = "abc@gmail.com"; | ||
|
||
String foo; | ||
|
||
@ParamRequired | ||
Integer boo; | ||
|
||
@ParamRequired | ||
Integer boo2 = 90; | ||
|
||
@ParamRequired | ||
InnerClass innerClass; | ||
|
||
InnerClass innerClass2; | ||
|
||
@ParamRequired | ||
InnerClass innerClass3 = new InnerClass(); | ||
|
||
@ParamOptional | ||
CastClass castClass; | ||
|
||
} | ||
|
||
class InnerClass { | ||
|
||
@ParamRequired | ||
String innerString; | ||
|
||
} | ||
|
||
class CastClass { | ||
|
||
@ParamOptional(rule = ValidatorRule.EMAIL) | ||
String name = "asdf@sdf.com"; | ||
|
||
@ParamOptional | ||
CastClass castClass; | ||
|
||
} | ||
|
||
class Foo { | ||
|
||
@ParamRequired | ||
String title; | ||
|
||
@ParamOptional | ||
String description; | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.0.1' | ||
|
||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Project-wide Gradle settings. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx1536m | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Tue Jan 23 11:16:53 EET 2018 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip |
Oops, something went wrong.