Skip to content
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

Kotlin Migration: Convert tests to Kotlin part 1 #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlinVersion = '1.3.50'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.6"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}

Expand Down
6 changes: 5 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "com.getkeepsafe.dexcount"
apply from: "gradle/script/coverage.gradle"

Expand Down Expand Up @@ -48,13 +49,15 @@ ext {
guavaVersion = "26.0-android"
junitVersion = "4.12"
mockitoVersion = "2.21.0"
mockitokotlinVersion = "2.2.0"
easymockVersion = "3.6"
powermockVersion = "2.0.0-beta.5"
}

dependencies {
implementation "com.android.support:design:${rootProject.ext.androidSupportLibVersion}"
implementation "com.android.support.constraint:constraint-layout:1.1.3"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${rootProject.ext.kotlinVersion}"
api("com.google.guava:guava:${guavaVersion}") {
exclude module: "jsr305"
}
Expand All @@ -64,6 +67,7 @@ dependencies {
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
testImplementation "org.powermock:powermock-api-easymock:${powermockVersion}"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitokotlinVersion"
}

configurations.all {
Expand All @@ -72,4 +76,4 @@ configurations.all {
}
}

apply from: "$rootProject.projectDir/publish.gradle"
apply from: "$rootProject.projectDir/publish.gradle"

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.basgeekball.awesomevalidation

import junit.framework.TestCase

import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4::class)
class ValidationStyleTest : TestCase() {

@Test
fun testFromValueToBasic() {
assertEquals(ValidationStyle.BASIC, ValidationStyle.fromValue(0))
}

@Test
fun testFromValueToColoration() {
assertEquals(ValidationStyle.COLORATION, ValidationStyle.fromValue(1))
}

@Test
fun testFromValueToUnderlabel() {
assertEquals(ValidationStyle.UNDERLABEL, ValidationStyle.fromValue(2))
}

@Test
fun testFromValueToTextInputLayout() {
assertEquals(ValidationStyle.TEXT_INPUT_LAYOUT, ValidationStyle.fromValue(3))
}

@Test(expected = IllegalArgumentException::class)
fun testFromValueThrowException() {
ValidationStyle.fromValue(4)
}
}