From 7593182a148eaec9d1bc524025e6194ab8a6808b Mon Sep 17 00:00:00 2001 From: "anthony.cicchetti" Date: Wed, 28 Feb 2018 13:48:00 -0500 Subject: [PATCH] Minor updates - Gradle to 4.6.0, updated :common/test --- .idea/gradle.xml | 5 +- .idea/misc.xml | 2 +- .idea/modules.xml | 4 ++ .idea/runConfigurations.xml | 12 ---- app/build.gradle | 2 +- build.gradle | 8 +++ common/src/main/kotlin/Money.kt | 4 ++ common/src/test/kotlin/MoneyTest.kt | 34 +++++----- gradlew | 100 ++++++++++++++++------------ gradlew.bat | 14 ++-- 10 files changed, 99 insertions(+), 86 deletions(-) delete mode 100644 .idea/runConfigurations.xml diff --git a/.idea/gradle.xml b/.idea/gradle.xml index c76116b..3907fce 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -3,8 +3,10 @@ diff --git a/.idea/misc.xml b/.idea/misc.xml index 75dac50..5473c6f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 0e72ba0..8e91188 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,8 +3,12 @@ + + + + diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index ed89936..f05af3a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,7 +29,7 @@ android { } dependencies { - compile project(':common') + implementation project(':common') implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:26.1.0' diff --git a/build.gradle b/build.gradle index 4520edb..0c22bfe 100644 --- a/build.gradle +++ b/build.gradle @@ -33,6 +33,14 @@ allprojects { ] } +//subprojects.findAll { !it.name.contains("app")}.each { p -> +// configure(p) { +// test { +// useJUnitPlatform() +// } +// } +//} + task clean(type: Delete) { delete rootProject.buildDir } \ No newline at end of file diff --git a/common/src/main/kotlin/Money.kt b/common/src/main/kotlin/Money.kt index 6499bed..89f26c4 100644 --- a/common/src/main/kotlin/Money.kt +++ b/common/src/main/kotlin/Money.kt @@ -9,6 +9,10 @@ data class Money(@JsonValue private val cents: Int) { return Money(this.cents - other.cents) } + override fun toString(): String { + return cents.toString() + } + companion object { fun fromDollarsAndCents(dollars: Int, cents: Int): Money { require((cents <= 99) and (cents >= 0)) diff --git a/common/src/test/kotlin/MoneyTest.kt b/common/src/test/kotlin/MoneyTest.kt index 2b30d2f..a278e2a 100644 --- a/common/src/test/kotlin/MoneyTest.kt +++ b/common/src/test/kotlin/MoneyTest.kt @@ -87,119 +87,119 @@ class MoneyTest { @Test fun `Positive Dollars`() { - val expectedResult = "$5.45" + val expectedResult = "545" val actualResult = Money(545).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Zero Dollars`() { - val expectedResult = "$0.50" + val expectedResult = "50" val actualResult = Money(50).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Negative Dollars`() { - val expectedResult = "-$5.66" + val expectedResult = "-566" val actualResult = Money(-566).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Add Positive and Positive Dollars`() { - val expectedResult = "$62.94" + val expectedResult = "6294" val actualResult = (Money(4265) + Money(2029)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Add Positive Dollars and Negative Dollars with Positive Result`() { - val expectedResult = "$1.32" + val expectedResult = "132" val actualResult = (Money(465) + Money(-333)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Add Positive Dollars and Negative Dollars with Negative Result`() { - val expectedResult = "-$5.27" + val expectedResult = "-527" val actualResult = (Money(100) + Money(-627)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Add Negative Dollars and Positive Dollars with Positive Result`() { - val expectedResult = "$1.32" + val expectedResult = "132" val actualResult = (Money(-333) + Money(465)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Add Negative Dollars and Positive Dollars with Negative Result`() { - val expectedResult = "-$5.73" + val expectedResult = "-573" val actualResult = (Money(-627) + Money(54)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Add Negative Dollars and Negative Dollars with Negative Result`() { - val expectedResult = "-$15.42" + val expectedResult = "-1542" val actualResult = (Money(-983) + Money(-559)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Subtract Positive Dollars and Positive Dollars with Positive Result`() { - val expectedResult = "$52.67" + val expectedResult = "5267" val actualResult = (Money(10054) - Money(4787)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Subtract Positive Dollars and Positive Dollars with Negative Result`() { - val expectedResult = "-$4.16" + val expectedResult = "-416" val actualResult = (Money(147) - Money(563)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Subtract Negative Dollars and Negative Dollars with Positive Result`() { - val expectedResult = "$7.89" + val expectedResult = "789" val actualResult = (Money(-563) - Money(-1352)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Subtract Negative Dollars and Negative Dollars with Negative Result`() { - val expectedResult = "-$9.64" + val expectedResult = "-964" val actualResult = (Money(-1563) - Money(-599)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Subtract Positive Dollars and Negative Dollars with Positive Result`() { - val expectedResult = "$176.84" + val expectedResult = "17684" val actualResult = (Money(12354) - Money(-5330)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `Subtract Negative Dollars and Positive Dollars with Negative Result`() { - val expectedResult = "-$5.68" + val expectedResult = "-568" val actualResult = (Money(-432) - Money(136)).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `From Positive Dollars and Cents`() { - val expectedResult = "$5.87" + val expectedResult = "587" val actualResult = Money.fromDollarsAndCents(5, 87).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } @Test fun `From Negative Dollars And Cents`() { - val expectedResult = "-$18.73" + val expectedResult = "-1873" val actualResult = Money.fromDollarsAndCents(-18, 73).toString() assertEquals(expectedResult, actualResult, "$expectedResult is not equal to $actualResult") } diff --git a/gradlew b/gradlew index 9d82f78..cccdd3d 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,42 +6,6 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -60,6 +24,46 @@ cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -150,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..f955316 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,10 +46,9 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +59,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line