|
| 1 | +package org.apereo.openlrw.risk; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | +import org.junit.Test; |
| 6 | +import java.util.Map; |
| 7 | + |
| 8 | +import static org.hamcrest.CoreMatchers.containsString; |
| 9 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 10 | + |
| 11 | + |
| 12 | +/** |
| 13 | + * @author xchopin <xavier.chopin@univ-lorraine.fr> |
| 14 | + */ |
| 15 | +public class RiskTest { |
| 16 | + @Test |
| 17 | + public void whenMinimallyPopulatedAllGood() throws JsonProcessingException { |
| 18 | + Map<String, String> testMetadata = java.util.Collections.singletonMap("meta", "data"); |
| 19 | + |
| 20 | + MongoRisk risk = new MongoRisk.Builder() |
| 21 | + .withSourcedId("risk-id") |
| 22 | + .withMetadata(testMetadata) |
| 23 | + .withActive(true) |
| 24 | + .withClassSourcedId("class-id") |
| 25 | + .withUserSourcedId("foobar") |
| 26 | + .withVelocity("-1.0") |
| 27 | + .withName("Computer Science - Semester 1 Risk") |
| 28 | + .build(); |
| 29 | + |
| 30 | + |
| 31 | + ObjectMapper mapper = new ObjectMapper(); |
| 32 | + String mapperResult = mapper.writeValueAsString(risk); |
| 33 | + assertThat(mapperResult, containsString("risk-id")); |
| 34 | + assertThat(mapperResult, containsString("class-id")); |
| 35 | + assertThat(mapperResult, containsString("foobar")); |
| 36 | + assertThat(mapperResult, containsString("-1.0")); |
| 37 | + assertThat(mapperResult, containsString("Computer Science - Semester 1 Risk")); |
| 38 | + assertThat(mapperResult, containsString("meta")); |
| 39 | + assertThat(mapperResult, containsString("data")); |
| 40 | + } |
| 41 | +} |
0 commit comments