Skip to content
Snippets Groups Projects
Unverified Commit 2d8585e8 authored by Peter Kurfer's avatar Peter Kurfer
Browse files

Updated to latest Gradle and project structure

parent 8fafca60
Branches
No related tags found
No related merge requests found
Showing
with 82 additions and 62 deletions
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = tab
indent_size = 4
[*.yml]
indent_style = space
indent_size = 2
\ No newline at end of file
language: java
dist: trusty
cache:
directories:
- $HOME/.m2
jdk:
- oraclejdk11
- openjdk11
os:
- linux
branches:
except: []
buildscript { plugins {
repositories { id 'java'
jcenter() id 'application'
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
}
} }
// Apply the java plugin to add support for Java sourceCompatibility = JavaVersion.VERSION_11
apply plugin: 'java'
// Apply the application plugin to add support for building an application
apply plugin: 'application'
apply plugin: 'com.github.ben-manes.versions'
repositories { repositories {
mavenCentral()
jcenter() jcenter()
} }
// Define the main class for the application // Define the main class for the application
mainClassName = 'App' mainClassName = 'de.thro.inf.prg3.a11.App'
dependencies { dependencies {
/* Commons Lang3 */ /* Commons Lang3 */
...@@ -32,9 +22,16 @@ dependencies { ...@@ -32,9 +22,16 @@ dependencies {
implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version" implementation "com.squareup.retrofit2:converter-gson:$retrofit2_version"
/* JUnit 5 */ /* JUnit 5 */
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}") testCompile("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}") testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
testRuntime("org.junit.platform:junit-platform-launcher:${junitPlatformVersion}") testRuntime("org.junit.jupiter:junit-jupiter-params:${junitVersion}")
testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}") testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}") testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
} }
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
commons_lang_version=3.7 commons_lang_version=3.8.1
retrofit2_version=2.3.0 retrofit2_version=2.5.0
junitPlatformVersion = 1.1.0-M1 log4jVersion = 2.11.1
junitJupiterVersion = 5.1.0-M1 junitVersion=5.3.1
log4jVersion = 2.10.0
\ No newline at end of file
No preview for this file type
#Thu Dec 13 17:32:22 CET 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
...@@ -28,7 +28,7 @@ APP_NAME="Gradle" ...@@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` 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. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
......
...@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0 ...@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% 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. @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 DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
......
package de.fhro.inf.prg3.a11; package de.thro.inf.prg3.a11;
import de.fhro.inf.prg3.a11.openmensa.OpenMensaAPI; import de.thro.inf.prg3.a11.openmensa.OpenMensaAPI;
import de.fhro.inf.prg3.a11.openmensa.OpenMensaAPIService; import de.thro.inf.prg3.a11.openmensa.OpenMensaAPIService;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
......
package de.fhro.inf.prg3.a11; package de.thro.inf.prg3.a11;
/** /**
* @author Peter Kurfer * @author Peter Kurfer
......
package de.fhro.inf.prg3.a11.openmensa; package de.thro.inf.prg3.a11.openmensa;
import de.fhro.inf.prg3.a11.openmensa.model.Canteen; import de.thro.inf.prg3.a11.openmensa.model.Canteen;
import de.fhro.inf.prg3.a11.openmensa.model.Meal; import de.thro.inf.prg3.a11.openmensa.model.Meal;
import de.fhro.inf.prg3.a11.openmensa.model.State; import de.thro.inf.prg3.a11.openmensa.model.State;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Path; import retrofit2.http.Path;
......
package de.fhro.inf.prg3.a11.openmensa; package de.thro.inf.prg3.a11.openmensa;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
......
package de.fhro.inf.prg3.a11.openmensa.model; package de.thro.inf.prg3.a11.openmensa.model;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
......
package de.fhro.inf.prg3.a11.openmensa.model; package de.thro.inf.prg3.a11.openmensa.model;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
......
package de.fhro.inf.prg3.a11.openmensa.model; package de.thro.inf.prg3.a11.openmensa.model;
import okhttp3.Headers; import okhttp3.Headers;
import retrofit2.Response; import retrofit2.Response;
import java.util.function.Function;
/** /**
* Utility class to handle HTTP response header containing the pagination information * Utility class to handle HTTP response header containing the pagination information
* required to fetch all pages of an entity * required to fetch all pages of an entity
......
package de.fhro.inf.prg3.a11.openmensa.model; package de.thro.inf.prg3.a11.openmensa.model;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
......
package de.fhro.inf.prg3.a11.tests; package de.thro.inf.prg3.a11.tests;
import de.fhro.inf.prg3.a11.openmensa.OpenMensaAPI; import de.thro.inf.prg3.a11.openmensa.OpenMensaAPI;
import de.fhro.inf.prg3.a11.openmensa.OpenMensaAPIService; import de.thro.inf.prg3.a11.openmensa.OpenMensaAPIService;
import de.fhro.inf.prg3.a11.openmensa.model.Canteen; import de.thro.inf.prg3.a11.openmensa.model.PageInfo;
import de.fhro.inf.prg3.a11.openmensa.model.PageInfo;
import de.fhro.inf.prg3.a11.openmensa.model.State;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import retrofit2.HttpException; import retrofit2.HttpException;
import retrofit2.Response;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
...@@ -23,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.*; ...@@ -23,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.*;
class OpenMensaApiTests { class OpenMensaApiTests {
private static final int FHRO_MENSA_ID = 229; private static final int THRO_MENSA_ID = 229;
private static final String OPEN_MENSA_DATE_FORMAT = "yyyy-MM-dd"; private static final String OPEN_MENSA_DATE_FORMAT = "yyyy-MM-dd";
private final SimpleDateFormat dateFormat; private final SimpleDateFormat dateFormat;
private final OpenMensaAPI openMensaAPI; private final OpenMensaAPI openMensaAPI;
...@@ -37,22 +33,22 @@ class OpenMensaApiTests { ...@@ -37,22 +33,22 @@ class OpenMensaApiTests {
@Test @Test
void testGetFirstMensaPage() throws ExecutionException, InterruptedException { void testGetFirstMensaPage() throws ExecutionException, InterruptedException {
Response<List<Canteen>> canteensResponse = openMensaAPI.getCanteens().get(); final var canteensResponse = openMensaAPI.getCanteens().get();
assertNotNull(canteensResponse); assertNotNull(canteensResponse);
assertNotNull(canteensResponse.body()); assertNotNull(canteensResponse.body());
assertNotEquals(0, canteensResponse.body().size()); assertNotEquals(0, canteensResponse.body().size());
for (Canteen c : canteensResponse.body()) { for (var c : canteensResponse.body()) {
System.out.println(c.getName()); System.out.println(c.getName());
} }
} }
@Test @Test
void testExtractPageInfo() throws ExecutionException, InterruptedException { void testExtractPageInfo() throws ExecutionException, InterruptedException {
Response<List<Canteen>> canteensResponse = openMensaAPI.getCanteens().get(); final var canteensResponse = openMensaAPI.getCanteens().get();
PageInfo pageInfo = PageInfo.extractFromResponse(canteensResponse); final var pageInfo = PageInfo.extractFromResponse(canteensResponse);
assertNotNull(pageInfo); assertNotNull(pageInfo);
assertEquals(canteensResponse.body().size(), pageInfo.getItemCountPerPage()); assertEquals(canteensResponse.body().size(), pageInfo.getItemCountPerPage());
...@@ -64,7 +60,7 @@ class OpenMensaApiTests { ...@@ -64,7 +60,7 @@ class OpenMensaApiTests {
@Test @Test
void testGetCanteenState() throws InterruptedException { void testGetCanteenState() throws InterruptedException {
try { try {
State mensaState = openMensaAPI.getCanteenState(FHRO_MENSA_ID, dateFormat.format(calendar.getTime())).get(); final var mensaState = openMensaAPI.getCanteenState(THRO_MENSA_ID, dateFormat.format(calendar.getTime())).get();
assertNotNull(mensaState); assertNotNull(mensaState);
}catch (ExecutionException e) { }catch (ExecutionException e) {
if(e.getCause() instanceof HttpException) { if(e.getCause() instanceof HttpException) {
...@@ -76,14 +72,14 @@ class OpenMensaApiTests { ...@@ -76,14 +72,14 @@ class OpenMensaApiTests {
@Test @Test
void testGetMultiplePages() throws ExecutionException, InterruptedException { void testGetMultiplePages() throws ExecutionException, InterruptedException {
Response<List<Canteen>> firstPage = openMensaAPI.getCanteens().get(); final var firstPage = openMensaAPI.getCanteens().get();
assertNotNull(firstPage); assertNotNull(firstPage);
assertNotNull(firstPage.body()); assertNotNull(firstPage.body());
PageInfo pageInfo = PageInfo.extractFromResponse(firstPage); final var pageInfo = PageInfo.extractFromResponse(firstPage);
for(int i = 2; i <= pageInfo.getTotalCountOfPages(); i++) { for(var i = 2; i <= pageInfo.getTotalCountOfPages(); i++) {
List<Canteen> canteensPage = openMensaAPI.getCanteens(i).get(); var canteensPage = openMensaAPI.getCanteens(i).get();
assertNotNull(canteensPage); assertNotNull(canteensPage);
assertNotEquals(0, canteensPage.size()); assertNotEquals(0, canteensPage.size());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment