|
| 1 | +package de.wuespace.telestion.api.verticle; |
| 2 | + |
| 3 | +import de.wuespace.telestion.api.message.JsonMessage; |
| 4 | +import org.junit.jupiter.api.Nested; |
| 5 | +import org.junit.jupiter.api.Test; |
| 6 | + |
| 7 | +import static org.hamcrest.Matchers.is; |
| 8 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 9 | + |
| 10 | +/** |
| 11 | + * <p> |
| 12 | + * <h1>Configuration Tests</h1> |
| 13 | + * Corresponding tests for the configuration classes provided by the Telestion Project. |
| 14 | + * </p> |
| 15 | + * <p> |
| 16 | + * <h2>{@link TelestionConfiguration}</h2> |
| 17 | + * This test checks if {@link TelestionConfiguration}: |
| 18 | + * <ul> |
| 19 | + * <li> |
| 20 | + * Is an Interface:<br/> |
| 21 | + * Records can only extend Interfaces - Messages or configurations primarily contain data which makes them a good |
| 22 | + * match |
| 23 | + * </li> |
| 24 | + * <li> |
| 25 | + * Extends {@link JsonMessage}:<br/> |
| 26 | + * To be serializable and used by other convenience methods of the Telestion Project |
| 27 | + * </li> |
| 28 | + * </ul> |
| 29 | + * </p> |
| 30 | + * <p> |
| 31 | + * <h2>Provided Configurations</h2> |
| 32 | + * In contrast to the base interface {@link TelestionConfiguration} the other provided Configurations: |
| 33 | + * <ul> |
| 34 | + * <li>Must implement {@link TelestionConfiguration} (to use all the features of the Telestion-Project)</li> |
| 35 | + * <li> |
| 36 | + * Should be a Record:<br/> |
| 37 | + * As these classes should only contain data, they are a prime example for records and therefore be |
| 38 | + * implemented like this. |
| 39 | + * </li> |
| 40 | + * <li>Can be instantiated (is neither abstract, nor an interface)</li> |
| 41 | + * </ul> |
| 42 | + * </p> |
| 43 | + * |
| 44 | + * @author Cedric Boes |
| 45 | + */ |
| 46 | +public final class ConfigurationTest { |
| 47 | + @Nested |
| 48 | + public class TelestionConfigTest { |
| 49 | + @Test |
| 50 | + public void shouldBeInterface() { |
| 51 | + // Needs to be an interface to be implemented by `Records` |
| 52 | + assertThat(TelestionConfiguration.class.isInterface(), is(true)); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void shouldExtendJsonMessage() { |
| 57 | + assertThat(JsonMessage.class.isAssignableFrom(TelestionConfiguration.class), is(true)); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + @Nested |
| 62 | + public class ProvidedConfigurationTest { |
| 63 | + @Test |
| 64 | + public void shouldImplementTelestionConfiguration() { |
| 65 | + assertThat(TelestionConfiguration.class.isAssignableFrom(NoConfiguration.class), is(true)); |
| 66 | + assertThat(TelestionConfiguration.class.isAssignableFrom(UntypedConfiguration.class), is(true)); |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + public void shouldBeRecord() { |
| 71 | + assertThat(NoConfiguration.class.isRecord(), is(true)); |
| 72 | + assertThat(UntypedConfiguration.class.isRecord(), is(true)); |
| 73 | + } |
| 74 | + |
| 75 | + @Test |
| 76 | + public void shouldBeInstantiable() { |
| 77 | + // Should not throw exceptions |
| 78 | + new NoConfiguration(); |
| 79 | + new UntypedConfiguration(); |
| 80 | + } |
| 81 | + } |
| 82 | +} |
0 commit comments