...
 
Commits (4)
......@@ -29,6 +29,9 @@
# build output
build
# images folder generated by the program
images
# package output
package
......
......@@ -11,6 +11,7 @@ build:
- build/
expire_in: 1h
script:
- mvn test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- ./scripts/build.sh
package-master:
......
......@@ -16,6 +16,10 @@
<version.maven.assembly.plugin>3.1.1</version.maven.assembly.plugin>
<version.maven.compiler.plugin>3.8.1</version.maven.compiler.plugin>
<!-- Testing -->
<version.junit>5.4.2</version.junit>
<version.maven.surfire.plugin>2.22.2</version.maven.surfire.plugin>
<jdk.source>11</jdk.source>
<jdk.target>11</jdk.target>
</properties>
......@@ -24,6 +28,7 @@
<module>app</module>
<module>pluginapi</module>
<module>plugins</module>
<module>tests</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>AnimeList</artifactId>
<groupId>at.shio</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>tests</artifactId>
<name>Unit Tests</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>at.shio</groupId>
<artifactId>pluginapi</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>at.shio</groupId>
<artifactId>anilist</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>at.shio</groupId>
<artifactId>omdb</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.maven.surfire.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.maven.compiler.plugin}</version>
<configuration>
<source>${jdk.source}</source>
<target>${jdk.target}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
import api.AniListClient;
import apicontracts.ApiClient;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class AnilistTests {
@Test
void apiSearch() {
ApiClient apiClient = new AniListClient();
var result = apiClient.search("Naruto");
assertTrue(result.isSuccess());
assertTrue(result.getValue().size() > 0);
}
}
import api.OmdbClient;
import apicontracts.ApiClient;
import apicontracts.KeyValueStore;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class OmdbTests {
@Test
void noApiKey() {
ApiClient apiClient = new OmdbClient();
var result = apiClient.search("Game of Thrones");
assertFalse(result.isSuccess());
}
@Test
void settingsTest() {
var someKey = "key123";
ApiClient apiClient = new OmdbClient();
var setting = apiClient.getApiSettings().get(0).getKey();
apiClient.persistSetting(setting, someKey);
var settingStore = KeyValueStore.instanceOf();
assertEquals(someKey, settingStore.get(setting));
}
@Test
void searchTest() {
var apiKey = System.getenv("OMDB_API_KEY");
if(apiKey != null) {
ApiClient apiClient = new OmdbClient();
var setting = apiClient.getApiSettings().get(0).getKey();
apiClient.persistSetting(setting, apiKey);
var result = apiClient.search("Game of Thrones");
assertTrue(result.isSuccess());
assertTrue(result.getValue().size() > 0);
}
}
}