41 lines
1.5 KiB
Java
41 lines
1.5 KiB
Java
package solutions.bitbadger.documents.java;
|
|
|
|
import org.junit.jupiter.api.DisplayName;
|
|
import org.junit.jupiter.api.Test;
|
|
import solutions.bitbadger.documents.DocumentException;
|
|
import solutions.bitbadger.documents.Parameter;
|
|
import solutions.bitbadger.documents.ParameterType;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
/**
|
|
* Unit tests for the `Parameter` class
|
|
*/
|
|
@DisplayName("JVM | Java | Parameter")
|
|
final public class ParameterTest {
|
|
|
|
@Test
|
|
@DisplayName("Construction with colon-prefixed name")
|
|
public void ctorWithColon() {
|
|
Parameter<String> p = new Parameter<>(":test", ParameterType.STRING, "ABC");
|
|
assertEquals(":test", p.getName(), "Parameter name was incorrect");
|
|
assertEquals(ParameterType.STRING, p.getType(), "Parameter type was incorrect");
|
|
assertEquals("ABC", p.getValue(), "Parameter value was incorrect");
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("Construction with at-sign-prefixed name")
|
|
public void ctorWithAtSign() {
|
|
Parameter<String> p = new Parameter<>("@yo", ParameterType.NUMBER, null);
|
|
assertEquals("@yo", p.getName(), "Parameter name was incorrect");
|
|
assertEquals(ParameterType.NUMBER, p.getType(), "Parameter type was incorrect");
|
|
assertNull(p.getValue(), "Parameter value was incorrect");
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("Construction fails with incorrect prefix")
|
|
public void ctorFailsForPrefix() {
|
|
assertThrows(DocumentException.class, () -> new Parameter<>("it", ParameterType.JSON, ""));
|
|
}
|
|
}
|