Merge branch 'master' of gitlab.ewi.tudelft.nl:cse1105/2018-2019/oopp-group-43/template
# Conflicts: # src/.idea/checkstyle-idea.xml # src/Client/src/main/java/greenify/client/controller/DashBoardController.java # src/Client/src/main/java/greenify/client/controller/UserController.java # src/Client/src/main/java/greenify/client/rest/UserService.java # src/Server/src/main/java/greenify/server/data/repository/UserRepository.java # src/Server/src/main/java/greenify/server/rest/UserController.java # src/Server/src/main/java/greenify/server/service/UserService.java
This commit is contained in:
@@ -1,188 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
This configuration file was written by the eclipse-cs plugin configuration editor
|
||||
-->
|
||||
<!--
|
||||
Checkstyle-Configuration: TI1216
|
||||
Description:
|
||||
Checkstyle configurartion that checks the Google coding conventions (https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html).
|
||||
-->
|
||||
<module name="Checker">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
<property name="max" value="100"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="TEXT"/>
|
||||
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="nl"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="EOL"/>
|
||||
<property name="tokens" value="COMMA"/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern" value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<message key="name.invalidPattern" value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<property name="allowOneCharVarInForLoop" value="true"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<message key="name.invalidPattern" value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.notPreceded" value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow" value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</module>
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
|
||||
<property name="specialImportsRegExp" value="com.google"/>
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
</module>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="JavadocTagContinuationIndentation"/>
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
</module>
|
||||
<module name="JavadocParagraph"/>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
<property name="ignoreInlineTags" value="false"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation"/>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="MethodLength"/>
|
||||
<module name="ParameterNumber"/>
|
||||
<module name="MethodCount">
|
||||
<property name="maxTotal" value="50"/>
|
||||
<property name="maxPrivate" value="50"/>
|
||||
<property name="maxPackage" value="50"/>
|
||||
<property name="maxProtected" value="50"/>
|
||||
<property name="maxPublic" value="50"/>
|
||||
</module>
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="DeclarationOrder"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="IllegalThrows"/>
|
||||
<module name="IllegalCatch"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="CyclomaticComplexity"/>
|
||||
</module>
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="FileLength"/>
|
||||
</module>
|
||||
48
build.gradle
48
build.gradle
@@ -16,44 +16,16 @@ apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'application'
|
||||
|
||||
application {
|
||||
mainClassName = 'greenify.server.Application'
|
||||
}
|
||||
|
||||
tasks.withType(Checkstyle) {
|
||||
reports {
|
||||
html.destination rootProject.file("build/reports/checkstyle.html")
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
allprojects {
|
||||
task hello {
|
||||
doLast { task ->
|
||||
println "I'm $task.project.name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////client bootjar
|
||||
//bootJar {
|
||||
// baseName = 'gs-consuming-rest'
|
||||
// version = '0.1.0'
|
||||
//}
|
||||
//
|
||||
////server bootjar
|
||||
//bootJar {
|
||||
// baseName = 'gs-rest-service'
|
||||
// version = '0.1.0'
|
||||
//}
|
||||
|
||||
bootJar {
|
||||
enabled = false
|
||||
}
|
||||
@@ -65,10 +37,6 @@ jar {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter")
|
||||
compile("org.springframework:spring-web")
|
||||
@@ -90,22 +58,6 @@ dependencies {
|
||||
)
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "0.8.3"
|
||||
reportsDir = file("$buildDir/customJacocoReportDir")
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
reports {
|
||||
xml.enabled false
|
||||
csv.enabled false
|
||||
html.destination file("${buildDir}/jacocoHtml")
|
||||
}
|
||||
}
|
||||
|
||||
task application(type: JavaExec, dependsOn: classes) {
|
||||
main = 'Cient.Application'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
188
quality/checkstyle/checkstyle.xml
Normal file
188
quality/checkstyle/checkstyle.xml
Normal file
@@ -0,0 +1,188 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
This configuration file was written by the eclipse-cs plugin configuration editor
|
||||
-->
|
||||
<!--
|
||||
Checkstyle-Configuration: TI1216
|
||||
Description:
|
||||
Checkstyle configurartion that checks the Google coding conventions (https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html).
|
||||
-->
|
||||
<module name="Checker">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
<property name="max" value="100"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="TEXT"/>
|
||||
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="nl"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="EOL"/>
|
||||
<property name="tokens" value="COMMA"/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern" value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<message key="name.invalidPattern" value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<property name="allowOneCharVarInForLoop" value="true"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<message key="name.invalidPattern" value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.notPreceded" value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow" value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</module>
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
|
||||
<property name="specialImportsRegExp" value="com.google"/>
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
</module>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="JavadocTagContinuationIndentation"/>
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
</module>
|
||||
<module name="JavadocParagraph"/>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
<property name="ignoreInlineTags" value="false"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation"/>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="MethodLength"/>
|
||||
<module name="ParameterNumber"/>
|
||||
<module name="MethodCount">
|
||||
<property name="maxTotal" value="50"/>
|
||||
<property name="maxPrivate" value="50"/>
|
||||
<property name="maxPackage" value="50"/>
|
||||
<property name="maxProtected" value="50"/>
|
||||
<property name="maxPublic" value="50"/>
|
||||
</module>
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="DeclarationOrder"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="IllegalThrows"/>
|
||||
<module name="IllegalCatch"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="CyclomaticComplexity"/>
|
||||
</module>
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="FileLength"/>
|
||||
</module>
|
||||
3
quality/checkstyle/suppression.xml
Normal file
3
quality/checkstyle/suppression.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="quality/checkstyle/suppressions.xml" />
|
||||
</module>
|
||||
@@ -13,32 +13,27 @@ apply plugin: 'idea'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'jacoco'
|
||||
//apply plugin: 'checkstyle'
|
||||
//
|
||||
//checkstyle {
|
||||
// version = '7.8.1'
|
||||
// config = 'checkstyle/checkstyle.xml' as File
|
||||
//}
|
||||
//
|
||||
//checkstyleMain {
|
||||
// source ='src/main/java'
|
||||
//}
|
||||
//
|
||||
//checkstyleTest {
|
||||
// source ='src/test/java'
|
||||
//}
|
||||
//
|
||||
//tasks.withType(Checkstyle) {
|
||||
// reports {
|
||||
// xml.enabled false
|
||||
// html.enabled true
|
||||
// html.stylesheet resources.text.fromFile('config/xsl/checkstyle-custom.xsl')
|
||||
// }
|
||||
//}
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
def configDir = "${project.rootDir}/quality"
|
||||
|
||||
checkstyle {
|
||||
toolVersion '7.8.1'
|
||||
configFile file("$configDir/checkstyle/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("$configDir/checkstyle/suppressions.xml").absolutePath
|
||||
}
|
||||
|
||||
checkstyleMain {
|
||||
source ='src/main/java'
|
||||
}
|
||||
|
||||
checkstyleTest {
|
||||
source ='src/test/java'
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application extends javafx.application.Application {
|
||||
private static ConfigurableApplicationContext springContext;
|
||||
@@ -19,16 +21,16 @@ public class Application extends javafx.application.Application {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
public static Parent load(java.net.URL url) {
|
||||
/**
|
||||
* This method takes an url and return a parent.
|
||||
* @param url which is being loaded.
|
||||
* @return parent object.
|
||||
*/
|
||||
public static Parent load(java.net.URL url) throws IOException {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setControllerFactory(springContext::getBean);
|
||||
loader.setLocation(url);
|
||||
try {
|
||||
return loader.load();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return loader.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,40 +6,28 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@Controller
|
||||
public class DashBoardController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
private int count = 0;
|
||||
|
||||
@FXML
|
||||
public AnchorPane menuBar;
|
||||
public AnchorPane dashboardPane;
|
||||
public AnchorPane userPane;
|
||||
public AnchorPane activitiesPane;
|
||||
public Label welcomebacktext;
|
||||
public Button dashboardButton;
|
||||
public Button activitiesButton;
|
||||
public Button userButton;
|
||||
public Label scoreField;
|
||||
|
||||
//activities buttons
|
||||
@FXML
|
||||
public Button veganMealButton;
|
||||
public Button localProduceButton;
|
||||
public Button bikeButton;
|
||||
public Button publicTransportButton;
|
||||
public Button temperatureButton;
|
||||
public Button solarPanelButton;
|
||||
|
||||
//activities counters
|
||||
public Label veganMealCounter;
|
||||
public Label localProduceCounter;
|
||||
public Label bikeCounter;
|
||||
public Label publicTransportCounter;
|
||||
public Label temperatureCounter;
|
||||
public Label solarPanelCounter;
|
||||
private AnchorPane menuBar;
|
||||
private AnchorPane dashboardPane;
|
||||
private AnchorPane userPane;
|
||||
private AnchorPane activitiesPane;
|
||||
private Label welcomebacktext;
|
||||
private Button dashboardButton;
|
||||
private Button activitiesButton;
|
||||
private Button userButton;
|
||||
private Button veganMealButton;
|
||||
private Label counter;
|
||||
private Label scoreField;
|
||||
|
||||
/**
|
||||
* displays the dashboard pane.
|
||||
@@ -47,16 +35,9 @@ public class DashBoardController {
|
||||
*/
|
||||
public void displayDashboard(ActionEvent event) {
|
||||
System.out.println("display dashboard");
|
||||
|
||||
// UserService service = new UserService();
|
||||
// UserDTO user = service.getName(null);
|
||||
// String name = user.getName();
|
||||
// welcomebacktext.setText("Welcome back, " + name);
|
||||
|
||||
dashboardPane.setVisible(true);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,10 +68,10 @@ public class DashBoardController {
|
||||
*/
|
||||
public void addVeganMeal(ActionEvent event) {
|
||||
count++;
|
||||
veganMealCounter.setText("Count: " + count);
|
||||
UserService service = new UserService();
|
||||
service.addVeganMeal(null, null);
|
||||
counter.setText("Count: " + count);
|
||||
System.out.println(userService);
|
||||
userService.addVeganMeal(userService.currentUser.getId(),
|
||||
userService.currentUser.getName());
|
||||
System.out.println("Vegetarian meal is added");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package greenify.client.rest;
|
||||
|
||||
import greenify.common.UserDTO;
|
||||
import greenify.common.UserDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -17,6 +17,8 @@ public class UserService {
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
public UserDto currentUser;
|
||||
|
||||
@Bean
|
||||
RestTemplate restTemplate(RestTemplateBuilder builder) {
|
||||
return builder.build();
|
||||
@@ -37,7 +39,10 @@ public class UserService {
|
||||
.queryParam("password", password);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
return this.restTemplate.getForObject(builder.build().encode().toUri(), UserDTO.class);
|
||||
UserDto result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), UserDto.class);
|
||||
this.currentUser = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +60,10 @@ public class UserService {
|
||||
.queryParam("password", password);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
return this.restTemplate.getForObject(builder.build().encode().toUri(), UserDTO.class);
|
||||
UserDto result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), UserDto.class);
|
||||
this.currentUser = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +81,7 @@ public class UserService {
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
return this.restTemplate.getForObject(builder.build().encode().toUri(), UserDTO.class);
|
||||
return this.restTemplate.getForObject(builder.build().encode().toUri(), UserDto.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import greenify.client.rest.UserService;
|
||||
import greenify.common.UserDTO;
|
||||
import greenify.common.UserDto;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.*;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -22,32 +25,32 @@ public class UserServiceTest {
|
||||
|
||||
@Test
|
||||
public void userRegisterTest() throws Exception {
|
||||
UserDTO testUser = new UserDTO(1L, "Eric");
|
||||
UserDto testUser = new UserDto(1L, "Eric");
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/registerUser?name=Eric&password=password"),
|
||||
UserDTO.class))
|
||||
UserDto.class))
|
||||
.thenReturn(testUser);
|
||||
|
||||
UserDTO user = userService.registerUser("Eric", "password");
|
||||
UserDto user = userService.registerUser("Eric", "password");
|
||||
Assert.assertEquals(testUser, user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userLoginTest() throws Exception {
|
||||
UserDTO testUser = new UserDTO(1L, "Eric");
|
||||
UserDto testUser = new UserDto(1L, "Eric");
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/loginUser?name=Eric&password=password"),
|
||||
UserDTO.class))
|
||||
UserDto.class))
|
||||
.thenReturn(testUser);
|
||||
UserDTO user = userService.loginUser("Eric", "password");
|
||||
UserDto user = userService.loginUser("Eric", "password");
|
||||
Assert.assertEquals(testUser, user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addVeganMealTest() throws Exception {
|
||||
UserDTO testUser = new UserDTO(1L, "Eric");
|
||||
UserDto testUser = new UserDto(1L, "Eric");
|
||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/addVeganMeal?id=1&name=Eric"),
|
||||
UserDTO.class))
|
||||
UserDto.class))
|
||||
.thenReturn(testUser);
|
||||
UserDTO user = userService.addVeganMeal(1L, "Eric");
|
||||
UserDto user = userService.addVeganMeal(1L, "Eric");
|
||||
Assert.assertEquals(testUser, user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
@@ -19,6 +20,22 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
def configDir = "${project.rootDir}/quality"
|
||||
|
||||
checkstyle {
|
||||
toolVersion '7.8.1'
|
||||
configFile file("$configDir/checkstyle/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("$configDir/checkstyle/suppressions.xml").absolutePath
|
||||
}
|
||||
|
||||
checkstyleMain {
|
||||
source ='src/main/java'
|
||||
}
|
||||
|
||||
checkstyleTest {
|
||||
source ='src/test/java'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile("junit:junit")
|
||||
testCompile(
|
||||
|
||||
@@ -4,15 +4,14 @@ package greenify.common;
|
||||
// is an object that carries data between processes.
|
||||
// The motivation for its use is that communication between processes is usually done
|
||||
// resorting to remote interfaces (e.g., web services), where each call is an expensive operation.
|
||||
public class UserDTO {
|
||||
|
||||
public class UserDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public UserDTO() {
|
||||
public UserDto() {
|
||||
}
|
||||
|
||||
public UserDTO(Long id, String name) {
|
||||
public UserDto(Long id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import greenify.common.ErrorResponse;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import greenify.common.ErrorResponse;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ErrorResponseTest {
|
||||
@Test
|
||||
public void setAndGetTest() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import greenify.common.UserDTO;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class UserDTOTest {
|
||||
import greenify.common.UserDto;
|
||||
import org.junit.Test;
|
||||
|
||||
public class UserDtoTest {
|
||||
@Test
|
||||
public void setAndGetTest() {
|
||||
UserDTO user = new UserDTO(1L, "greenify");
|
||||
UserDTO testUser = new UserDTO();
|
||||
UserDto user = new UserDto(1L, "greenify");
|
||||
UserDto testUser = new UserDto();
|
||||
testUser.setId(1L);
|
||||
testUser.setName("greenify");
|
||||
assertTrue(user.getId() == 1L);
|
||||
@@ -17,8 +17,8 @@ public class UserDTOTest {
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
UserDTO first = new UserDTO(1L, "greenify");
|
||||
UserDTO second = new UserDTO(1L, "greenify");
|
||||
UserDto first = new UserDto(1L, "greenify");
|
||||
UserDto second = new UserDto(1L, "greenify");
|
||||
assertEquals(first.getId(), second.getId());
|
||||
assertEquals(first.getName(), second.getName());
|
||||
}
|
||||
@@ -13,6 +13,7 @@ apply plugin: 'idea'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
bootJar {
|
||||
baseName = 'gs-rest-service'
|
||||
@@ -31,6 +32,22 @@ repositories {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
def configDir = "${project.rootDir}/quality"
|
||||
|
||||
checkstyle {
|
||||
toolVersion '7.8.1'
|
||||
configFile file("$configDir/checkstyle/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("$configDir/checkstyle/suppressions.xml").absolutePath
|
||||
}
|
||||
|
||||
checkstyleMain {
|
||||
source ='src/main/java'
|
||||
}
|
||||
|
||||
checkstyleTest {
|
||||
source ='src/test/java'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
|
||||
@@ -3,7 +3,11 @@ package greenify.server.data.model;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@EnableAutoConfiguration
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package greenify.server.rest;
|
||||
|
||||
import greenify.common.UserDTO;
|
||||
import greenify.common.UserDto;
|
||||
import greenify.server.data.model.User;
|
||||
import greenify.server.data.repository.UserRepository;
|
||||
import greenify.server.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@@ -14,14 +17,14 @@ public class UserController {
|
||||
UserService userService;
|
||||
|
||||
@RequestMapping("/registerUser")
|
||||
public UserDTO registerUser(@RequestParam(value = "name") String name,
|
||||
public UserDto registerUser(@RequestParam(value = "name") String name,
|
||||
@RequestParam(value = "password") String password) {
|
||||
return userService.registerUser(name, password);
|
||||
}
|
||||
|
||||
@RequestMapping("/loginUser")
|
||||
public UserDTO loginUser(@RequestParam(value = "name") String name,
|
||||
@RequestParam(value = "password") String password) {
|
||||
public UserDto loginUser(@RequestParam(value = "name") String name,
|
||||
@RequestParam(value = "password") String password) {
|
||||
return userService.loginUser(name, password);
|
||||
}
|
||||
|
||||
@@ -34,5 +37,12 @@ public class UserController {
|
||||
@GetMapping("/getUsername")
|
||||
public void getUsername(@RequestParam(value = "id") Long id) {
|
||||
userService.getUsername(id);
|
||||
|
||||
|
||||
@GetMapping(path = "/all")
|
||||
@ResponseBody
|
||||
public Iterable<User> getAllUsers() {
|
||||
// This returns a JSON or XML with the users
|
||||
return userRepository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
import greenify.server.Application;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package greenify.server.data.model;
|
||||
|
||||
import greenify.server.data.model.User;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class UserTest {
|
||||
@Test
|
||||
public void setAndGetTest() {
|
||||
User user = new User(1L, "greenify", "password", 3);
|
||||
User testUser = new User();
|
||||
testUser.setId(1L);
|
||||
testUser.setName("greenify");
|
||||
testUser.setPassword("password");
|
||||
testUser.setVeganMeal(3);
|
||||
User user = new User(1L, "greenify", "password", 3);
|
||||
assertTrue(user.getId().equals(1L));
|
||||
assertEquals(user.getName(), "greenify");
|
||||
assertEquals(user.getPassword(), "password");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//package greenify.server.rest;
|
||||
//
|
||||
//import greenify.common.UserDTO;
|
||||
//import greenify.common.UserDto;
|
||||
//import greenify.server.data.model.User;
|
||||
//import greenify.server.service.UserService;
|
||||
//import org.junit.Test;
|
||||
@@ -40,16 +40,18 @@
|
||||
// @Test
|
||||
// public void getVehicleWhenRequestingTextShouldReturnMakeAndModel() throws Exception {
|
||||
// given(this.userService.loginUser("name", "password"))
|
||||
// .willReturn(new UserDTO(1L, "name"));
|
||||
// .willReturn(new UserDto(1L, "name"));
|
||||
// this.mvc.perform(get("/loginUser").accept(MediaType.APPLICATION_JSON))
|
||||
// .andExpect(status().isOk()).andExpect(content().json("name=name, password=password"));
|
||||
// .andExpect(status().isOk())
|
||||
// .andExpect(content()
|
||||
// .json("name=name, password=password"));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void givenEmployees_whenGetEmployees_thenReturnJsonArray() throws Exception {
|
||||
// User alex = new User(1L, "alex", "password", 0);
|
||||
// UserDTO user = userService.loginUser("alex", "password");
|
||||
// UserDto user = userService.loginUser("alex", "password");
|
||||
// given(userService.loginUser("alex", "password")).willReturn(user);
|
||||
// mvc.perform(get("/loginUser")
|
||||
// .contentType(MediaType.ALL))
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package greenify.server.service;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import greenify.common.ApplicationException;
|
||||
import greenify.common.UserDTO;
|
||||
import greenify.common.UserDto;
|
||||
import greenify.server.data.model.User;
|
||||
import greenify.server.data.repository.UserRepository;
|
||||
import org.junit.Before;
|
||||
@@ -12,9 +16,6 @@ import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public class UserServiceTest {
|
||||
@@ -32,6 +33,9 @@ public class UserServiceTest {
|
||||
@MockBean
|
||||
private UserRepository userRepository;
|
||||
|
||||
/**
|
||||
* setUp method for test.
|
||||
*/
|
||||
@Before
|
||||
public void setUp() {
|
||||
User alex = new User(1L, "alex", "password", 0);
|
||||
@@ -43,18 +47,18 @@ public class UserServiceTest {
|
||||
public void validLoginTest() {
|
||||
String name = "alex";
|
||||
String password = "password";
|
||||
UserDTO found = userService.loginUser(name, password);
|
||||
UserDto found = userService.loginUser(name, password);
|
||||
assertEquals(found.getName(), name);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void addVeganMealTest() {
|
||||
// User user = new User(1L, "x", "y", 3);
|
||||
// userRepository.save(user);
|
||||
// System.out.println(userRepository);
|
||||
// userService.addVeganMeal(1L, "x");
|
||||
// assertEquals(user.getVeganMeal(), 7);
|
||||
// }
|
||||
// @Test
|
||||
// public void addVeganMealTest() {
|
||||
// User user = new User(1L, "x", "y", 3);
|
||||
// userRepository.save(user);
|
||||
// System.out.println(userRepository);
|
||||
// userService.addVeganMeal(1L, "x");
|
||||
// assertEquals(user.getVeganMeal(), 7);
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void invalidLoginTest() {
|
||||
|
||||
Reference in New Issue
Block a user