Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Simionescu Laurentiu committed Jan 28, 2018
1 parent 058fc1a commit 192c73b
Show file tree
Hide file tree
Showing 23 changed files with 881 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions app/build.gradle
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')

}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
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
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="com.laurentiusimionescu.validator"/>
121 changes: 121 additions & 0 deletions app/src/test/java/com/laurentiusimionescu/validator/ValidatorTest.java
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;

}


}
27 changes: 27 additions & 0 deletions build.gradle
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
}
17 changes: 17 additions & 0 deletions gradle.properties
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 added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
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
Loading

0 comments on commit 192c73b

Please sign in to comment.