mirror of
https://github.com/brmlab/wekan-mailer.git
synced 2025-06-09 10:24:21 +02:00
Create test for wekan config
This commit is contained in:
parent
5e93948620
commit
e6ae8b22d0
2 changed files with 99 additions and 0 deletions
7
pom.xml
7
pom.xml
|
@ -37,6 +37,13 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.stefanbirkner</groupId>
|
||||
<artifactId>system-rules</artifactId>
|
||||
<version>1.18.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
92
src/test/java/cz/brmlab/wm/wekan/WekanConfigurationTest.java
Normal file
92
src/test/java/cz/brmlab/wm/wekan/WekanConfigurationTest.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
package cz.brmlab.wm.wekan;
|
||||
|
||||
import cz.brmlab.wm.utils.Exceptions.BrmException;
|
||||
import cz.brmlab.wm.utils.Exceptions.ExitCode;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.contrib.java.lang.system.EnvironmentVariables;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class WekanConfigurationTest {
|
||||
|
||||
@Rule
|
||||
public final EnvironmentVariables environmentVariables
|
||||
= new EnvironmentVariables();
|
||||
|
||||
private static final String WEKAN_URL = "WEKAN_URL";
|
||||
private static final String WEKAN_URL_VALUE = "wekan.test.url";
|
||||
|
||||
private static final String WEKAN_USER = "WEKAN_USER";
|
||||
private static final String WEKAN_USER_VALUE = "someuser";
|
||||
|
||||
private static final String WEKAN_PASSWORD = "WEKAN_PASSWORD";
|
||||
private static final String WEKAN_PASSWORD_VALUE = "somepass";
|
||||
|
||||
private static final String WEKAN_TARGET_BOARD = "WEKAN_TARGET_BOARD";
|
||||
private static final String WEKAN_TARGET_BOARD_VALUE = "someboardif";
|
||||
|
||||
private static final String WEKAN_TARGET_LIST = "WEKAN_TARGET_LIST";
|
||||
private static final String WEKAN_TARGET_LIST_VALUE = "somelistid";
|
||||
|
||||
|
||||
@After
|
||||
public void cleanEnvVars() {
|
||||
environmentVariables.clear(WEKAN_URL, WEKAN_USER, WEKAN_PASSWORD, WEKAN_TARGET_BOARD, WEKAN_TARGET_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configurationOk() {
|
||||
environmentVariables.set(WEKAN_URL, WEKAN_URL_VALUE);
|
||||
environmentVariables.set(WEKAN_USER, WEKAN_USER_VALUE);
|
||||
environmentVariables.set(WEKAN_PASSWORD, WEKAN_PASSWORD_VALUE);
|
||||
environmentVariables.set(WEKAN_TARGET_BOARD, WEKAN_TARGET_BOARD_VALUE);
|
||||
environmentVariables.set(WEKAN_TARGET_LIST, WEKAN_TARGET_LIST_VALUE);
|
||||
|
||||
|
||||
WekanConfiguration configuration = null;
|
||||
try {
|
||||
configuration = new WekanConfiguration();
|
||||
} catch (BrmException e) {
|
||||
fail("OK configuration should not throw an error!");
|
||||
}
|
||||
assertEquals(WEKAN_URL_VALUE, configuration.getWekanUrl());
|
||||
assertEquals(WEKAN_USER_VALUE, configuration.getWekanUser());
|
||||
assertEquals(WEKAN_PASSWORD_VALUE, configuration.getWekanPassword());
|
||||
assertEquals(WEKAN_TARGET_BOARD_VALUE, configuration.getWekanBoard());
|
||||
assertEquals(WEKAN_TARGET_LIST_VALUE, configuration.getWekanList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allConfigurationMissing() {
|
||||
WekanConfiguration configuration = null;
|
||||
try {
|
||||
configuration = new WekanConfiguration();
|
||||
fail("Missing whole configuration should not throw an error!");
|
||||
} catch (BrmException ignored) {
|
||||
|
||||
}
|
||||
assertNull(null, configuration);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingOneProp() {
|
||||
|
||||
environmentVariables.set(WEKAN_URL, WEKAN_URL_VALUE);
|
||||
environmentVariables.set(WEKAN_USER, WEKAN_USER_VALUE);
|
||||
//environmentVariables.set(WEKAN_PASSWORD, WEKAN_PASSWORD_VALUE);
|
||||
environmentVariables.set(WEKAN_TARGET_BOARD, WEKAN_TARGET_BOARD_VALUE);
|
||||
environmentVariables.set(WEKAN_TARGET_LIST, WEKAN_TARGET_LIST_VALUE);
|
||||
|
||||
WekanConfiguration configuration = null;
|
||||
try {
|
||||
configuration = new WekanConfiguration();
|
||||
fail("Missing one property in configuration should not throw an error!");
|
||||
} catch (BrmException ex) {
|
||||
assertEquals(ExitCode.CONFIGURATION_MISSING.getReason() + WEKAN_PASSWORD, ex.getMessage());
|
||||
}
|
||||
assertNull(null, configuration);
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue