diff --git a/backend/src/main/java/uk/co/neviyn/Observations/api/NewObservation.java b/backend/src/main/java/uk/co/neviyn/Observations/api/NewObservation.java index 1a9dc3a..b8cad17 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/api/NewObservation.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/api/NewObservation.java @@ -22,7 +22,7 @@ public class NewObservation { @NonNull @JsonProperty - private String observed, type; + private String observed, type, whom; @NonNull @JsonProperty diff --git a/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java b/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java index afb3cba..8f913b5 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/core/Observation.java @@ -39,6 +39,10 @@ public class Observation implements Serializable { @JsonProperty private String observed; + @NonNull + @JsonProperty + private String whom; + @NonNull @JsonProperty private TrainingType type; diff --git a/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java b/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java index 175a33b..f7ed89a 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java @@ -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); } diff --git a/backend/src/test/java/uk/co/neviyn/Observations/api/NewObservationTest.java b/backend/src/test/java/uk/co/neviyn/Observations/api/NewObservationTest.java index 8a3f6e2..ad6f122 100644 --- a/backend/src/test/java/uk/co/neviyn/Observations/api/NewObservationTest.java +++ b/backend/src/test/java/uk/co/neviyn/Observations/api/NewObservationTest.java @@ -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 { diff --git a/backend/src/test/java/uk/co/neviyn/Observations/core/ObservationTest.java b/backend/src/test/java/uk/co/neviyn/Observations/core/ObservationTest.java index 1773762..cfce1fa 100644 --- a/backend/src/test/java/uk/co/neviyn/Observations/core/ObservationTest.java +++ b/backend/src/test/java/uk/co/neviyn/Observations/core/ObservationTest.java @@ -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(); diff --git a/backend/src/test/java/uk/co/neviyn/Observations/dao/ObservationDaoTest.java b/backend/src/test/java/uk/co/neviyn/Observations/dao/ObservationDaoTest.java index 13f3e6f..c7f2b4d 100644 --- a/backend/src/test/java/uk/co/neviyn/Observations/dao/ObservationDaoTest.java +++ b/backend/src/test/java/uk/co/neviyn/Observations/dao/ObservationDaoTest.java @@ -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(); diff --git a/backend/src/test/java/uk/co/neviyn/Observations/resources/ObservationResourceTest.java b/backend/src/test/java/uk/co/neviyn/Observations/resources/ObservationResourceTest.java index 708df0e..3f4a807 100644 --- a/backend/src/test/java/uk/co/neviyn/Observations/resources/ObservationResourceTest.java +++ b/backend/src/test/java/uk/co/neviyn/Observations/resources/ObservationResourceTest.java @@ -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)); } diff --git a/backend/src/test/resources/fixtures/NewObservation.json b/backend/src/test/resources/fixtures/NewObservation.json index 1fe1e4e..4d80c4d 100644 --- a/backend/src/test/resources/fixtures/NewObservation.json +++ b/backend/src/test/resources/fixtures/NewObservation.json @@ -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, diff --git a/backend/src/test/resources/fixtures/Observation.json b/backend/src/test/resources/fixtures/Observation.json index 653b743..5b505de 100644 --- a/backend/src/test/resources/fixtures/Observation.json +++ b/backend/src/test/resources/fixtures/Observation.json @@ -1,6 +1,7 @@ { "id":0, "observed":"Just a test observation", + "whom": "Group A", "type":"INITIAL", "monitoring":1, "control":2,