Added field for who was observed.
This commit is contained in:
parent
40ad371748
commit
20599d48fd
@ -22,7 +22,7 @@ public class NewObservation {
|
||||
|
||||
@NonNull
|
||||
@JsonProperty
|
||||
private String observed, type;
|
||||
private String observed, type, whom;
|
||||
|
||||
@NonNull
|
||||
@JsonProperty
|
||||
|
@ -39,6 +39,10 @@ public class Observation implements Serializable {
|
||||
@JsonProperty
|
||||
private String observed;
|
||||
|
||||
@NonNull
|
||||
@JsonProperty
|
||||
private String whom;
|
||||
|
||||
@NonNull
|
||||
@JsonProperty
|
||||
private TrainingType type;
|
||||
|
@ -48,7 +48,7 @@ public class ObservationResource {
|
||||
.type(TrainingType.valueOf(newObservation.getType())).monitoring(newObservation.getMonitoring())
|
||||
.control(newObservation.getControl()).conservatism(newObservation.getConservatism())
|
||||
.teamwork(newObservation.getTeamwork()).knowledge(newObservation.getKnowledge())
|
||||
.observations(newObservation.getRawData()).date(submissionDate).build();
|
||||
.observations(newObservation.getRawData()).date(submissionDate).whom(newObservation.getWhom()).build();
|
||||
for (Tutor t : tutors) {
|
||||
t.getObservations().add(observation);
|
||||
}
|
||||
|
@ -9,14 +9,15 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static io.dropwizard.testing.FixtureHelpers.fixture;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class NewObservationTest {
|
||||
|
||||
private static final ObjectMapper mapper = Jackson.newObjectMapper();
|
||||
|
||||
private final NewObservation newObservation = new NewObservation(1, Arrays.asList(1L, 2L, 3L), "A random thing made for testing.",
|
||||
"INITIAL", 1, 2, 3, 4, 5, Collections.singletonList(new ObservationEntry("MONITORING", 5, "some", "another sum")));
|
||||
private final NewObservation newObservation = NewObservation.builder().siteId(1).tutorIds(Arrays.asList(1L, 2L, 3L))
|
||||
.observed("A random thing made for testing.").whom("Group A").type("INITIAL").monitoring(1).control(2).conservatism(3)
|
||||
.teamwork(4).knowledge(5).rawData(Collections.singletonList(new ObservationEntry("MONITORING", 5, "some", "another sum"))).build();
|
||||
|
||||
@Test
|
||||
public void serializesToJson() throws Exception {
|
||||
|
@ -16,7 +16,7 @@ public class ObservationTest {
|
||||
private static final ObjectMapper mapper = Jackson.newObjectMapper();
|
||||
|
||||
private final Observation observation = Observation.builder().observed("Just a test observation").type(TrainingType.INITIAL)
|
||||
.monitoring(1).control(2).conservatism(3).teamwork(4).knowledge(5)
|
||||
.monitoring(1).control(2).conservatism(3).teamwork(4).knowledge(5).whom("Group A")
|
||||
.observations(Collections.singletonList(new ObservationEntry("MONITORING", 5, "some", "another sum")))
|
||||
.date(DateTime.parse("2018-09-18T00:00:00.000Z")).build();
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class ObservationDaoTest extends DaoTestBase {
|
||||
private final Site site = Site.builder().name("Test site").build();
|
||||
|
||||
private final Observation observation = Observation.builder().observed("Just a test observation").type(TrainingType.INITIAL)
|
||||
.site(site).monitoring(1).control(2).conservatism(3).teamwork(4).knowledge(5)
|
||||
.site(site).monitoring(1).control(2).conservatism(3).teamwork(4).knowledge(5).whom("Group A")
|
||||
.observations(Collections.singletonList(new ObservationEntry("MONITORING", 5, "some", "another sum")))
|
||||
.date(DateTime.parse("2018-09-18T00:00:00.000Z")).build();
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class ObservationResourceTest {
|
||||
when(tutorDao.get(2)).thenReturn(tutors.get(1));
|
||||
resources.target("/observation").request().post(Entity.json(NewObservation.builder().type("INITIAL")
|
||||
.conservatism(1).control(2).knowledge(3).monitoring(4).teamwork(5).siteId(1).tutorIds(Arrays.asList(1L, 2L))
|
||||
.observed("").rawData(new ArrayList<>()).build()));
|
||||
.observed("").whom("Group A").rawData(new ArrayList<>()).build()));
|
||||
verify(dao, times(1)).persist(any(Observation.class));
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
"siteId":1,
|
||||
"tutorIds":[1,2,3],
|
||||
"observed":"A random thing made for testing.",
|
||||
"whom": "Group A",
|
||||
"type":"INITIAL",
|
||||
"monitoring":1,
|
||||
"control":2,
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"id":0,
|
||||
"observed":"Just a test observation",
|
||||
"whom": "Group A",
|
||||
"type":"INITIAL",
|
||||
"monitoring":1,
|
||||
"control":2,
|
||||
|
Loading…
Reference in New Issue
Block a user