diff --git a/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStateRequestTests.java b/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStateRequestTests.java index 77ab035f..c4ffb980 100644 --- a/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStateRequestTests.java +++ b/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStateRequestTests.java @@ -7,6 +7,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; + import dev.learning.xapi.client.DeleteStateRequest.Builder; import java.net.URI; import java.util.HashMap; @@ -27,7 +28,7 @@ class DeleteStateRequestTests { void whenBuildingDeleteStateRequestWithAllParametersThenNoExceptionIsThrown() { // When Building DeleteStateRequest With All Parameters - Builder builder = DeleteStateRequest.builder() + final Builder builder = DeleteStateRequest.builder() .activityId("https://example.com/activity/1") @@ -46,7 +47,7 @@ void whenBuildingDeleteStateRequestWithAllParametersThenNoExceptionIsThrown() { void whenBuildingDeleteStateRequestWithoutRegistrationThenNoExceptionIsThrown() { // When Building DeleteStateRequest Without Registration - Builder builder = DeleteStateRequest.builder() + final Builder builder = DeleteStateRequest.builder() .activityId("https://example.com/activity/1") @@ -63,7 +64,7 @@ void whenBuildingDeleteStateRequestWithoutRegistrationThenNoExceptionIsThrown() void whenBuildingDeleteStateRequestWithoutActivityIdThenExceptionIsThrown() { // When Building DeleteStateRequest Without ActivityId - Builder builder = DeleteStateRequest.builder() + final Builder builder = DeleteStateRequest.builder() .agent(a -> a.name("A N Other").mbox("another@example.com")) @@ -80,7 +81,7 @@ void whenBuildingDeleteStateRequestWithoutActivityIdThenExceptionIsThrown() { void whenBuildingDeleteStateRequestWithoutAgentThenExceptionIsThrown() { // When Building DeleteStateRequest Without Agent - Builder builder = DeleteStateRequest.builder() + final Builder builder = DeleteStateRequest.builder() .activityId("https://example.com/activity/1") @@ -97,7 +98,7 @@ void whenBuildingDeleteStateRequestWithoutAgentThenExceptionIsThrown() { void whenBuildingDeleteStateRequestWithoutStateIdThenExceptionIsThrown() { // When Building DeleteStateRequest Without StateId - Builder builder = DeleteStateRequest.builder() + final Builder builder = DeleteStateRequest.builder() .activityId("https://example.com/activity/1") @@ -114,7 +115,7 @@ void whenBuildingDeleteStateRequestWithoutStateIdThenExceptionIsThrown() { void givenDeleteStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { // Given DeleteStateRequest With All Parameters - DeleteStateRequest request = DeleteStateRequest.builder() + final DeleteStateRequest request = DeleteStateRequest.builder() .activityId("https://example.com/activity/1") @@ -126,16 +127,16 @@ void givenDeleteStateRequestWithAllParametersWhenGettingURLThenResultIsExpected( .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22another%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22another%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); } @@ -143,7 +144,7 @@ void givenDeleteStateRequestWithAllParametersWhenGettingURLThenResultIsExpected( void givenDeleteStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() { // Given DeleteStateRequest Without Registration - DeleteStateRequest request = DeleteStateRequest.builder() + final DeleteStateRequest request = DeleteStateRequest.builder() .activityId("https://example.com/activity/1") @@ -153,16 +154,16 @@ void givenDeleteStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpecte .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22another%40example.com%22%7D&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22another%40example.com%22%7D&stateId=bookmark"))); } diff --git a/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStatesRequestTests.java b/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStatesRequestTests.java index 6ec5ec94..4eba7b47 100644 --- a/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStatesRequestTests.java +++ b/xapi-client/src/test/java/dev/learning/xapi/client/DeleteStatesRequestTests.java @@ -7,6 +7,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; + import dev.learning.xapi.client.DeleteStatesRequest.Builder; import java.net.URI; import java.util.HashMap; @@ -28,7 +29,7 @@ class DeleteStatesRequestTests { void whenBuildingDeleteStatesRequestWithAllParametersThenNoExceptionIsThrown() { // When Building DeleteStatesRequest With All Parameters - Builder builder = DeleteStatesRequest.builder() + final Builder builder = DeleteStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -45,7 +46,7 @@ void whenBuildingDeleteStatesRequestWithAllParametersThenNoExceptionIsThrown() { void whenBuildingDeleteStatesRequestWithRegistrationAsUUIDTypeThenNoExceptionIsThrown() { // When Building Delete States Request With Registration As UUID Type - Builder builder = DeleteStatesRequest.builder() + final Builder builder = DeleteStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -62,13 +63,13 @@ void whenBuildingDeleteStatesRequestWithRegistrationAsUUIDTypeThenNoExceptionIsT void whenBuildingDeleteStatesRequestWithActivityIdAsURITypeThenNoExceptionIsThrown() { // When Building Delete States Request With ActivityId As URI Type - Builder builder = DeleteStatesRequest.builder() + final Builder builder = DeleteStatesRequest.builder() .activityId(URI.create("https://example.com/activity/1")) .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")) - .registration(("67828e3a-d116-4e18-8af3-2d2c59e27be6")); + .registration("67828e3a-d116-4e18-8af3-2d2c59e27be6"); // Then No Exception Is Thrown assertDoesNotThrow(() -> builder.build()); @@ -79,7 +80,7 @@ void whenBuildingDeleteStatesRequestWithActivityIdAsURITypeThenNoExceptionIsThro void whenBuildingDeleteStatesRequestWithoutRegistrationThenNoExceptionIsThrown() { // When Building DeleteStatesRequest Without Registration - Builder builder = DeleteStatesRequest.builder() + final Builder builder = DeleteStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -94,7 +95,7 @@ void whenBuildingDeleteStatesRequestWithoutRegistrationThenNoExceptionIsThrown() void whenBuildingDeleteStatesRequestWithoutActivityIdThenExceptionIsThrown() { // When Building DeleteStatesRequest Without ActivityId - Builder builder = DeleteStatesRequest.builder() + final Builder builder = DeleteStatesRequest.builder() .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")) @@ -109,7 +110,7 @@ void whenBuildingDeleteStatesRequestWithoutActivityIdThenExceptionIsThrown() { void whenBuildingDeleteStatesRequestWithoutAgentThenExceptionIsThrown() { // When Building DeleteStatesRequest Without Agent - Builder builder = DeleteStatesRequest.builder() + final Builder builder = DeleteStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -124,7 +125,7 @@ void whenBuildingDeleteStatesRequestWithoutAgentThenExceptionIsThrown() { void givenDeleteStatesRequestWithAllParametersWhenGettingURLThenResultIsExpected() { // Given DeleteStatesRequest With All Parameters - DeleteStatesRequest request = DeleteStatesRequest.builder() + final DeleteStatesRequest request = DeleteStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -134,25 +135,24 @@ void givenDeleteStatesRequestWithAllParametersWhenGettingURLThenResultIsExpected .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI url = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI url = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(url, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6"))); } - @Test void givenDeleteStatesRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() { // Given DeleteStatesRequest Without Registration - DeleteStatesRequest request = DeleteStatesRequest.builder() + final DeleteStatesRequest request = DeleteStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -160,16 +160,16 @@ void givenDeleteStatesRequestWithoutRegistrationWhenGettingURLThenResultIsExpect .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI url = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI url = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(url, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D"))); } diff --git a/xapi-client/src/test/java/dev/learning/xapi/client/GetStateRequestTests.java b/xapi-client/src/test/java/dev/learning/xapi/client/GetStateRequestTests.java index 75acbfbe..58a9b07b 100644 --- a/xapi-client/src/test/java/dev/learning/xapi/client/GetStateRequestTests.java +++ b/xapi-client/src/test/java/dev/learning/xapi/client/GetStateRequestTests.java @@ -7,6 +7,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + import dev.learning.xapi.client.GetStateRequest.Builder; import java.net.URI; import java.util.HashMap; @@ -27,7 +28,7 @@ class GetStateRequestTests { void whenBuildingGetStateRequestWithAllParametersThenNoExceptionIsThrown() { // When Building GetStateRequest With All Parameters - Builder builder = GetStateRequest.builder() + final Builder builder = GetStateRequest.builder() .activityId("https://example.com/activity/1") @@ -46,7 +47,7 @@ void whenBuildingGetStateRequestWithAllParametersThenNoExceptionIsThrown() { void whenBuildingGetStateRequestWithoutRegistrationThenNoExceptionIsThrown() { // When Building GetStateRequest Without Registration - Builder builder = GetStateRequest.builder() + final Builder builder = GetStateRequest.builder() .activityId("https://example.com/activity/1") @@ -63,7 +64,7 @@ void whenBuildingGetStateRequestWithoutRegistrationThenNoExceptionIsThrown() { void whenBuildingGetStateRequestWithoutActivityIdThenNullPointerExceptionIsThrown() { // When Building GetStateRequest Without activityId - Builder builder = GetStateRequest.builder() + final Builder builder = GetStateRequest.builder() .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")) @@ -78,7 +79,7 @@ void whenBuildingGetStateRequestWithoutActivityIdThenNullPointerExceptionIsThrow void whenBuildingGetStateRequestWithoutAgentThenNullPointerExceptionIsThrown() { // When Building GetStateRequest Without Agent - Builder builder = GetStateRequest.builder() + final Builder builder = GetStateRequest.builder() .activityId("https://example.com/activity/1") @@ -93,7 +94,7 @@ void whenBuildingGetStateRequestWithoutAgentThenNullPointerExceptionIsThrown() { void whenBuildingGetStateRequestWithoutStateIdThenNullPointerExceptionIsThrown() { // When Building GetStateRequest Without StateId - Builder builder = GetStateRequest.builder() + final Builder builder = GetStateRequest.builder() .activityId("https://example.com/activity/1") @@ -108,7 +109,7 @@ void whenBuildingGetStateRequestWithoutStateIdThenNullPointerExceptionIsThrown() void givenGetStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { // Given GetStateRequest With All Parameters - GetStateRequest request = GetStateRequest.builder() + final GetStateRequest request = GetStateRequest.builder() .activityId("https://example.com/activity/1") @@ -120,16 +121,16 @@ void givenGetStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); } @@ -137,7 +138,7 @@ void givenGetStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { void givenGetStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() { // Given GetStateRequest Without Registration - GetStateRequest request = GetStateRequest.builder() + final GetStateRequest request = GetStateRequest.builder() .activityId("https://example.com/activity/1") @@ -147,16 +148,16 @@ void givenGetStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark"))); } diff --git a/xapi-client/src/test/java/dev/learning/xapi/client/GetStatesRequestTests.java b/xapi-client/src/test/java/dev/learning/xapi/client/GetStatesRequestTests.java index 4611708c..03f3210c 100644 --- a/xapi-client/src/test/java/dev/learning/xapi/client/GetStatesRequestTests.java +++ b/xapi-client/src/test/java/dev/learning/xapi/client/GetStatesRequestTests.java @@ -7,6 +7,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + import dev.learning.xapi.client.GetStatesRequest.Builder; import java.net.URI; import java.time.Instant; @@ -28,7 +29,7 @@ class GetStatesRequestTests { void whenBuildingGetStatesRequestWithAllParametersThenNoExceptionIsThrown() { // When Building GetStatesRequest With All Parameters - Builder builder = GetStatesRequest.builder() + final Builder builder = GetStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -47,7 +48,7 @@ void whenBuildingGetStatesRequestWithAllParametersThenNoExceptionIsThrown() { void whenBuildingGetStatesRequestWithoutSinceParameterThenNoExceptionIsThrown() { // When Building GetStatesRequest Without Since Parameter - Builder builder = GetStatesRequest.builder() + final Builder builder = GetStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -64,7 +65,7 @@ void whenBuildingGetStatesRequestWithoutSinceParameterThenNoExceptionIsThrown() void whenBuildingGetStatesRequestWithoutRegistrationParameterThenNoExceptionIsThrown() { // When Building GetStatesRequest Without Registration Parameter - Builder builder = GetStatesRequest.builder() + final Builder builder = GetStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -79,7 +80,7 @@ void whenBuildingGetStatesRequestWithoutRegistrationParameterThenNoExceptionIsTh void whenBuildingGetStatesRequestWithRequiredParametersThenNoExceptionIsThrown() { // When Building GetStatesRequest With Required Parameters - Builder builder = GetStatesRequest.builder() + final Builder builder = GetStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -94,7 +95,7 @@ void whenBuildingGetStatesRequestWithRequiredParametersThenNoExceptionIsThrown() void whenBuildingGetStatesRequestWithoutActivityIdThenNullPointerExceptionIsThrown() { // When Building GetStatesRequest Without ActivityId - Builder builder = GetStatesRequest.builder() + final Builder builder = GetStatesRequest.builder() .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")); @@ -107,7 +108,7 @@ void whenBuildingGetStatesRequestWithoutActivityIdThenNullPointerExceptionIsThro void whenBuildingGetStatesRequestWithoutAgentThenNullPointerExceptionIsThrown() { // When Building GetStatesRequest Without Agent - Builder builder = GetStatesRequest.builder() + final Builder builder = GetStatesRequest.builder() .activityId("https://example.com/activity/1"); @@ -120,7 +121,7 @@ void whenBuildingGetStatesRequestWithoutAgentThenNullPointerExceptionIsThrown() void givenGetStatesRequestWithAllParametersWhenGettingURLThenResultIsExpected() { // Given GetStatesRequest With All Parameters - GetStatesRequest request = GetStatesRequest.builder() + final GetStatesRequest request = GetStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -132,16 +133,16 @@ void givenGetStatesRequestWithAllParametersWhenGettingURLThenResultIsExpected() .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&since=2016-01-01T00:00:00Z"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&since=2016-01-01T00:00:00Z"))); } @@ -149,7 +150,7 @@ void givenGetStatesRequestWithAllParametersWhenGettingURLThenResultIsExpected() void givenGetStatesRequestWithoutRegistrationParameterWhenGettingURLThenResultIsExpected() { // Given GetStatesRequest Without Registration Parameter - GetStatesRequest request = GetStatesRequest.builder() + final GetStatesRequest request = GetStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -157,16 +158,16 @@ void givenGetStatesRequestWithoutRegistrationParameterWhenGettingURLThenResultIs .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D"))); } @@ -174,7 +175,7 @@ void givenGetStatesRequestWithoutRegistrationParameterWhenGettingURLThenResultIs void givenGetStatesRequestWithoutSinceParameterWhenGettingURLThenResultIsExpected() { // Given GetStatesRequest Without Since Parameter - GetStatesRequest request = GetStatesRequest.builder() + final GetStatesRequest request = GetStatesRequest.builder() .activityId("https://example.com/activity/1") @@ -184,16 +185,16 @@ void givenGetStatesRequestWithoutSinceParameterWhenGettingURLThenResultIsExpecte .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6"))); } diff --git a/xapi-client/src/test/java/dev/learning/xapi/client/PostStateRequestTests.java b/xapi-client/src/test/java/dev/learning/xapi/client/PostStateRequestTests.java index f6004599..b3e58f9a 100644 --- a/xapi-client/src/test/java/dev/learning/xapi/client/PostStateRequestTests.java +++ b/xapi-client/src/test/java/dev/learning/xapi/client/PostStateRequestTests.java @@ -6,6 +6,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + import dev.learning.xapi.client.PostStateRequest.Builder; import java.net.URI; import java.util.HashMap; @@ -26,7 +27,7 @@ class PostStateRequestTests { void whenBuildingPostStateRequestWithAllParametersThenNoExceptionIsThrown() { // When Building PostStateRequest With All Parameters - Builder builder = PostStateRequest.builder() + final Builder builder = PostStateRequest.builder() .activityId("https://example.com/activity/1") @@ -47,7 +48,7 @@ void whenBuildingPostStateRequestWithAllParametersThenNoExceptionIsThrown() { void givenPostStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { // Given PostStateRequest With All Parameters - PostStateRequest request = PostStateRequest.builder() + final PostStateRequest request = PostStateRequest.builder() .activityId("https://example.com/activity/1") @@ -61,16 +62,16 @@ void givenPostStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); } @@ -78,7 +79,7 @@ void givenPostStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() void givenPostStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() { // Given PostStateRequest Without Registration - PostStateRequest request = PostStateRequest.builder() + final PostStateRequest request = PostStateRequest.builder() .activityId("https://example.com/activity/1") @@ -90,16 +91,16 @@ void givenPostStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpected( .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark"))); } diff --git a/xapi-client/src/test/java/dev/learning/xapi/client/PutStateRequestTests.java b/xapi-client/src/test/java/dev/learning/xapi/client/PutStateRequestTests.java index be780814..07cbbb8d 100644 --- a/xapi-client/src/test/java/dev/learning/xapi/client/PutStateRequestTests.java +++ b/xapi-client/src/test/java/dev/learning/xapi/client/PutStateRequestTests.java @@ -6,6 +6,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + import dev.learning.xapi.client.PutStateRequest.Builder; import java.net.URI; import java.util.HashMap; @@ -26,7 +27,7 @@ class PutStateRequestTests { void whenBuildingPutStateRequestWithAllParametersThenNoExceptionIsThrown() { // When Building PutStateRequest With All Parameters - Builder builder = PutStateRequest.builder() + final Builder builder = PutStateRequest.builder() .activityId("https://example.com/activity/1") @@ -47,7 +48,7 @@ void whenBuildingPutStateRequestWithAllParametersThenNoExceptionIsThrown() { void givenPutStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { // Given PutStateRequest With All Parameters - PutStateRequest request = PutStateRequest.builder() + final PutStateRequest request = PutStateRequest.builder() .activityId("https://example.com/activity/1") @@ -61,16 +62,16 @@ void givenPutStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark"))); } @@ -78,7 +79,7 @@ void givenPutStateRequestWithAllParametersWhenGettingURLThenResultIsExpected() { void givenPutStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() { // Given PutStateRequest Without Registration - PutStateRequest request = PutStateRequest.builder() + final PutStateRequest request = PutStateRequest.builder() .activityId("https://example.com/activity/1") @@ -90,16 +91,16 @@ void givenPutStateRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() .build(); - Map queryParams = new HashMap<>(); + final Map queryParams = new HashMap<>(); // When Getting URL - URI result = - request.url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) - .build(queryParams); + final URI result = request + .url(UriComponentsBuilder.fromUriString("https://example.com/xapi/"), queryParams) + .build(queryParams); // Then Result Is Expected assertThat(result, is(URI.create( - "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark"))); + "https://example.com/xapi/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark"))); } diff --git a/xapi-client/src/test/java/dev/learning/xapi/client/XapiClientTests.java b/xapi-client/src/test/java/dev/learning/xapi/client/XapiClientTests.java index fb6a0d68..6feeb2a0 100644 --- a/xapi-client/src/test/java/dev/learning/xapi/client/XapiClientTests.java +++ b/xapi-client/src/test/java/dev/learning/xapi/client/XapiClientTests.java @@ -6,6 +6,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsInstanceOf.instanceOf; + import dev.learning.xapi.model.About; import dev.learning.xapi.model.Activity; import dev.learning.xapi.model.Person; @@ -71,7 +72,7 @@ void whenGettingStatementThenMethodIsGet() throws InterruptedException { // When Getting Statements client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -85,7 +86,7 @@ void whenGettingStatementThenPathIsExpected() throws InterruptedException { // When Getting Statement client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -102,7 +103,8 @@ void whenGettingStatementThenBodyIsInstanceOfStatement() throws InterruptedExcep .addHeader("Content-Type", "application/json; charset=utf-8")); // When Getting Statement - var response = client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6")).block(); + final var response = client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6")) + .block(); // Then Body Is Instance Of Statement assertThat(response.getBody(), instanceOf(Statement.class)); @@ -117,7 +119,7 @@ void whenGettingStatementWithAttachmentsThenPathIsExpected() throws InterruptedE client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6").attachments(true)) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -135,7 +137,7 @@ void whenGettingStatementWithCanonicalFormatThenPathIsExpected() throws Interrup r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6").format(StatementFormat.CANONICAL)) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -162,12 +164,12 @@ void whenPostingStatementsThenMethodIsPost() throws InterruptedException { final Statement passedStatement = attemptedStatement.toBuilder().verb(Verb.PASSED).build(); - Statement statements[] = {attemptedStatement, passedStatement}; + final Statement statements[] = { attemptedStatement, passedStatement }; // When posting Statements client.postStatements(r -> r.statements(statements)).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("POST")); @@ -191,16 +193,16 @@ void whenPostingStatementsThenBodyIsExpected() throws InterruptedException { final Statement passedStatement = attemptedStatement.toBuilder().verb(Verb.PASSED).build(); - Statement statements[] = {attemptedStatement, passedStatement}; + final Statement statements[] = { attemptedStatement, passedStatement }; // When Posting Statements client.postStatements(r -> r.statements(statements)).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Body Is Expected assertThat(recordedRequest.getBody().readUtf8(), is( - "[{\"actor\":{\"name\":\"A N Other\",\"mbox\":\"mailto:another@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/attempted\",\"display\":{\"und\":\"attempted\"}},\"object\":{\"objectType\":\"Activity\",\"id\":\"https://example.com/activity/simplestatement\",\"definition\":{\"name\":{\"en\":\"Simple Statement\"}}}},{\"actor\":{\"name\":\"A N Other\",\"mbox\":\"mailto:another@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/passed\",\"display\":{\"und\":\"passed\"}},\"object\":{\"objectType\":\"Activity\",\"id\":\"https://example.com/activity/simplestatement\",\"definition\":{\"name\":{\"en\":\"Simple Statement\"}}}}]")); + "[{\"actor\":{\"objectType\":\"Agent\",\"name\":\"A N Other\",\"mbox\":\"mailto:another@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/attempted\",\"display\":{\"und\":\"attempted\"}},\"object\":{\"objectType\":\"Activity\",\"id\":\"https://example.com/activity/simplestatement\",\"definition\":{\"name\":{\"en\":\"Simple Statement\"}}}},{\"actor\":{\"objectType\":\"Agent\",\"name\":\"A N Other\",\"mbox\":\"mailto:another@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/passed\",\"display\":{\"und\":\"passed\"}},\"object\":{\"objectType\":\"Activity\",\"id\":\"https://example.com/activity/simplestatement\",\"definition\":{\"name\":{\"en\":\"Simple Statement\"}}}}]")); } @Test @@ -221,12 +223,12 @@ void whenPostingStatementsThenContentTypeHeaderIsApplicationJson() throws Interr final Statement passedStatement = attemptedStatement.toBuilder().verb(Verb.PASSED).build(); - Statement statements[] = {attemptedStatement, passedStatement}; + final Statement statements[] = { attemptedStatement, passedStatement }; // When Posting Statements client.postStatements(r -> r.statements(statements)).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -253,10 +255,11 @@ void whenPostingStatementsThenResponseBodyIsInstanceOfUUIDArray() throws Interru final Statement passedStatement = attemptedStatement.toBuilder().verb(Verb.PASSED).build(); - Statement statements[] = {attemptedStatement, passedStatement}; + final Statement statements[] = { attemptedStatement, passedStatement }; // When Posting Statements - ResponseEntity response = client.postStatements(r -> r.statements(statements)).block(); + final ResponseEntity< + UUID[]> response = client.postStatements(r -> r.statements(statements)).block(); // Then Response Body Is Instance Of UUID Array assertThat(response.getBody(), instanceOf(UUID[].class)); @@ -281,7 +284,7 @@ void whenPostingStatementThenMethodIsPost() throws InterruptedException { .definition(d -> d.addName(Locale.ENGLISH, "Simple Statement"))))) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("POST")); @@ -304,11 +307,11 @@ void whenPostingStatementThenBodyIsExpected() throws InterruptedException { .definition(d -> d.addName(Locale.ENGLISH, "Simple Statement"))))) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Body Is Expected assertThat(recordedRequest.getBody().readUtf8(), is( - "{\"actor\":{\"name\":\"A N Other\",\"mbox\":\"mailto:another@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/attempted\",\"display\":{\"und\":\"attempted\"}},\"object\":{\"objectType\":\"Activity\",\"id\":\"https://example.com/activity/simplestatement\",\"definition\":{\"name\":{\"en\":\"Simple Statement\"}}}}")); + "{\"actor\":{\"objectType\":\"Agent\",\"name\":\"A N Other\",\"mbox\":\"mailto:another@example.com\"},\"verb\":{\"id\":\"http://adlnet.gov/expapi/verbs/attempted\",\"display\":{\"und\":\"attempted\"}},\"object\":{\"objectType\":\"Activity\",\"id\":\"https://example.com/activity/simplestatement\",\"definition\":{\"name\":{\"en\":\"Simple Statement\"}}}}")); } @Test @@ -328,7 +331,7 @@ void whenPostingStatementThenContentTypeHeaderIsApplicationJson() throws Interru .definition(d -> d.addName(Locale.ENGLISH, "Simple Statement"))))) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -342,10 +345,10 @@ void whenGettingVoidedStatementThenMethodIsGet() throws InterruptedException { mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK")); // When Getting Voided Statement - client.getVoidedStatement(r -> r.voidedId(UUID.fromString("4df42866-40e7-45b6-bf7c-8d5fccbdccd6"))) - .block(); + client.getVoidedStatement( + r -> r.voidedId(UUID.fromString("4df42866-40e7-45b6-bf7c-8d5fccbdccd6"))).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -359,7 +362,7 @@ void whenGettingVoidedStatementThenPathIsExpected() throws InterruptedException // When Getting Voided Statement client.getVoidedStatement(r -> r.voidedId("4df42866-40e7-45b6-bf7c-8d5fccbdccd6")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -375,7 +378,7 @@ void whenGettingVoidedStatementWithAttachmentsThenPathIsExpected() throws Interr client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6").attachments(true)) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -394,7 +397,7 @@ void whenGettingVoidedStatementWithCanonicalFormatThenPathIsExpected() r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6").format(StatementFormat.CANONICAL)) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -411,7 +414,7 @@ void whenGettingStatementsThenMethodIsGet() throws InterruptedException { // When Getting Statements client.getStatements().block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -425,7 +428,7 @@ void whenGettingStatementsThenPathIsExpected() throws InterruptedException { // When Getting Statements client.getStatements().block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is("/statements")); @@ -465,11 +468,11 @@ void whenGettingStatementsWithAllParametersThenPathIsExpected() throws Interrupt ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/statements?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&verb=http%3A%2F%2Fadlnet.gov%2Fexpapi%2Fverbs%2Fanswered&activity=https%3A%2F%2Fexample.com%2Factivity%2F1&since=2016-01-01T00%3A00%3A00Z&until=2018-01-01T00%3A00%3A00Z®istration=dbf5d9e8-d2aa-4d57-9754-b11e3f195fe3&related_activities=true&related_agents=true&limit=10&format=canonical&attachments=true&ascending=true")); + "/statements?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&verb=http%3A%2F%2Fadlnet.gov%2Fexpapi%2Fverbs%2Fanswered&activity=https%3A%2F%2Fexample.com%2Factivity%2F1&since=2016-01-01T00%3A00%3A00Z&until=2018-01-01T00%3A00%3A00Z®istration=dbf5d9e8-d2aa-4d57-9754-b11e3f195fe3&related_activities=true&related_agents=true&limit=10&format=canonical&attachments=true&ascending=true")); } @Test @@ -484,11 +487,11 @@ void whenGettingStatementsWithAgentParameterThenPathIsExpected() throws Interrup ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/statements?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); + "/statements?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); } @Test @@ -503,7 +506,7 @@ void whenGettingStatementsWithVerbParameterThenPathIsExpected() throws Interrupt ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -522,7 +525,7 @@ void whenGettingStatementsWithActivityParameterThenPathIsExpected() throws Inter ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -541,7 +544,7 @@ void whenGettingMoreStatementsThenRequestMethodIsGet() throws InterruptedExcepti ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -559,7 +562,7 @@ void whenGettingMoreStatementsThenRequestURLExpected() throws InterruptedExcepti ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Request URL Is Expected assertThat(recordedRequest.getRequestUrl(), @@ -582,7 +585,7 @@ void whenGettingASingleStateThenMethodIsGet() throws InterruptedException { .stateId("bookmark"), String.class).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -602,11 +605,11 @@ void whenGettingASingleStateThenPathIsExpected() throws InterruptedException { .stateId("bookmark"), String.class).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); } @Test @@ -623,7 +626,7 @@ void whenGettingASingleStateWithoutRegistrationThenMethodIsGet() throws Interrup .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -643,11 +646,11 @@ void whenGettingASingleStateWithoutRegistrationThenPathIsExpected() throws Inter .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark")); } @Test @@ -659,7 +662,7 @@ void givenStateContentTypeIsTextPlainWhenGettingStateThenBodyIsInstanceOfString( .addHeader("Content-Type", "text/plain; charset=utf-8")); // When Getting State - ResponseEntity response = client + final ResponseEntity response = client .getState(r -> r.activityId("https://example.com/activity/1") .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")) @@ -683,7 +686,7 @@ void givenStateContentTypeIsTextPlainWhenGettingStateThenBodyIsExpected() .addHeader("Content-Type", "text/plain; charset=utf-8")); // When Getting State - ResponseEntity response = client + final ResponseEntity response = client .getState(r -> r.activityId("https://example.com/activity/1") .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")) @@ -718,7 +721,7 @@ void whenPostingASingleStateThenMethodIsPost() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("POST")); @@ -742,11 +745,11 @@ void whenPostingASingleStateThenPathIsExpected() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); } @Test @@ -770,7 +773,7 @@ void whenPostingASingleStateWithContentTypeTextPlainThenContentTypeHeaderIsTextP .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Text Plain assertThat(recordedRequest.getHeader("content-type"), is("text/plain")); @@ -795,7 +798,7 @@ void whenPostingASingleStateWithoutContentTypeThenContentTypeHeaderIsApplication .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -817,7 +820,7 @@ void whenPostingASingleStateWithoutRegistrationThenMethodIsPost() throws Interru .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("POST")); @@ -839,11 +842,11 @@ void whenPostingASingleStateWithoutRegistrationThenPathIsExpected() throws Inter .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark")); } // Put Single State @@ -866,7 +869,7 @@ void whenPuttingASingleStateThenMethodIsPut() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("PUT")); @@ -890,11 +893,11 @@ void whenPuttingASingleStateThenPathIsExpected() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); } @Test @@ -918,7 +921,7 @@ void whenPuttingASingleStateWithContentTypeTextPlainThenContentTypeHeaderIsTextP .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Text Plain assertThat(recordedRequest.getHeader("content-type"), is("text/plain")); @@ -943,7 +946,7 @@ void whenPuttingASingleStateWithoutContentTypeThenContentTypeHeaderIsApplication .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -965,7 +968,7 @@ void whenPuttingASingleStateWithoutRegistrationThenMethodIsPut() throws Interrup .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("PUT")); @@ -987,11 +990,11 @@ void whenPuttingASingleStateWithoutRegistrationThenPathIsExpected() throws Inter .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&stateId=bookmark")); } // Deleting Single State @@ -1010,7 +1013,7 @@ void whenDeletingASingleStateThenMethodIsDelete() throws InterruptedException { .stateId("bookmark")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Delete assertThat(recordedRequest.getMethod(), is("DELETE")); @@ -1030,11 +1033,11 @@ void whenDeletingASingleStateThenPathIsExpected() throws InterruptedException { .stateId("bookmark")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); } @Test @@ -1049,7 +1052,7 @@ void whenDeletingASingleStateWithoutRegistrationThenMethodIsDelete() throws Inte .stateId("bookmark")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Delete assertThat(recordedRequest.getMethod(), is("DELETE")); @@ -1069,11 +1072,11 @@ void whenDeletingASingleStateWithoutRegistrationThenPathIsExpected() throws Inte .stateId("bookmark")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6&stateId=bookmark")); } // Getting Multiple States @@ -1094,7 +1097,7 @@ void whenGettingMultipleStatesThenMethodIsGet() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1116,11 +1119,11 @@ void whenGettingMultipleStatesThenPathIsExpected() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6")); } @Test @@ -1137,7 +1140,7 @@ void whenGettingMultipleStatesWithoutRegistrationThenMethodIsGet() throws Interr .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1158,11 +1161,11 @@ void whenGettingMultipleStatesWithoutRegistrationThenPathIsExpected() .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); } @Test @@ -1175,7 +1178,7 @@ void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsInstanceOfString .addHeader("Content-Type", "application/json; charset=utf-8")); // When Getting Multiple States - ResponseEntity response = client + final ResponseEntity response = client .getStates(r -> r.activityId("https://example.com/activity/1") .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")) @@ -1198,7 +1201,7 @@ void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsExpected() .addHeader("Content-Type", "application/json; charset=utf-8")); // When Getting Multiple States - ResponseEntity response = client + final ResponseEntity response = client .getStates(r -> r.activityId("https://example.com/activity/1") .agent(a -> a.name("A N Other").mbox("mailto:another@example.com")) @@ -1208,7 +1211,7 @@ void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsExpected() .block(); // Then Body Is Expected - assertThat(response.getBody(), is(new String[] {"State1", "State2", "State3"})); + assertThat(response.getBody(), is(new String[] { "State1", "State2", "State3" })); } // Deleting Multiple States @@ -1227,7 +1230,7 @@ void whenDeletingMultipleStatesThenMethodIsDelete() throws InterruptedException ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Delete assertThat(recordedRequest.getMethod(), is("DELETE")); @@ -1247,11 +1250,11 @@ void whenDeletingMultipleStatesThenPathIsExpected() throws InterruptedException ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D®istration=67828e3a-d116-4e18-8af3-2d2c59e27be6")); } @Test @@ -1267,7 +1270,7 @@ void whenDeletingMultipleStatesWithoutRegistrationThenMethodIsDelete() ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Delete assertThat(recordedRequest.getMethod(), is("DELETE")); @@ -1286,11 +1289,11 @@ void whenDeletingMultipleStatesWithoutRegistrationThenPathIsExpected() ).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); + "/activities/state?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); } // Get Single Agent Profile @@ -1305,7 +1308,7 @@ void whenGettingASingleAgentProfileThenMethodIsGet() throws InterruptedException .profileId("greeting"), String.class).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1325,11 +1328,11 @@ void whenGettingASingleAgentProfileThenPathIsExpected() throws InterruptedExcept .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/agents/profile?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); + "/agents/profile?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); } // Delete Single Agent Profile @@ -1348,7 +1351,7 @@ void whenDeletingASingleAgentProfileThenMethodIsDelete() throws InterruptedExcep .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Delete assertThat(recordedRequest.getMethod(), is("DELETE")); @@ -1366,11 +1369,11 @@ void whenDeletetingASingleAgentProfileThenPathIsExpected() throws InterruptedExc .profileId("greeting")) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/agents/profile?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); + "/agents/profile?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); } // Put Single Agent Profile @@ -1389,7 +1392,7 @@ void whenPuttingASingleAgentProfileThenMethodIsPut() throws InterruptedException .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Put assertThat(recordedRequest.getMethod(), is("PUT")); @@ -1409,11 +1412,11 @@ void whenPuttingASingleAgentProfileThenPathIsExpected() throws InterruptedExcept .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/agents/profile?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); + "/agents/profile?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); } @Test @@ -1433,7 +1436,7 @@ void whenPuttingASingleAgentProfileWithContentTypeTextPlainThenContentTypeHeader .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Text Plain assertThat(recordedRequest.getHeader("content-type"), is("text/plain")); @@ -1454,7 +1457,7 @@ void whenPuttingASingleAgentProfileWithoutContentTypeThenContentTypeHeaderIsAppl .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -1477,7 +1480,7 @@ void whenPuttingASingleAgentProfileWithoutContentTypeThenBodyIsExpected() .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Body Is Expected assertThat(recordedRequest.getBody().readUtf8(), @@ -1501,7 +1504,7 @@ void whenPostingASingleAgentProfileThenMethodIsPost() throws InterruptedExceptio .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("POST")); @@ -1522,11 +1525,11 @@ void whenPostingASingleAgentProfileThenPathIsExpected() throws InterruptedExcept .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/agents/profile?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); + "/agents/profile?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&profileId=greeting")); } @Test @@ -1547,7 +1550,7 @@ void whenPostingASingleAgentProfileWithContentTypeTextPlainThenContentTypeHeader .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Text Plain assertThat(recordedRequest.getHeader("content-type"), is("text/plain")); @@ -1569,7 +1572,7 @@ void whenPostingASingleAgentProfileWithoutContentTypeThenContentTypeHeaderIsAppl .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -1593,7 +1596,7 @@ void whenPostingASingleAgentProfileWithoutContentTypeThenBodyIsExpected() .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Body Is Expected assertThat(recordedRequest.getBody().readUtf8(), @@ -1613,7 +1616,7 @@ void whenGettingProfilesThenMethodIsGet() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1632,11 +1635,11 @@ void whenGettingProfilesThenPathIsExpected() throws InterruptedException { .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/agents/profile?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); + "/agents/profile?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); } @Test @@ -1654,11 +1657,11 @@ void whenGettingProfilesWithSinceParameterThenPathIsExpected() throws Interrupte .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( - "/agents/profile?agent=%7B%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&since=2016-01-01T00%3A00%3A00Z")); + "/agents/profile?agent=%7B%22objectType%22%3A%22Agent%22%2C%22name%22%3A%22A%20N%20Other%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D&since=2016-01-01T00%3A00%3A00Z")); } // Get Activity @@ -1673,7 +1676,7 @@ void whenGettingActivityByUriThenMethodIsGet() throws InterruptedException { .getActivity(r -> r.activityId(URI.create("https://example.com/activity/simplestatement"))) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1685,16 +1688,14 @@ void whenGettingActivityByStringThenMethodIsGet() throws InterruptedException { mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK")); // When Getting Activity By String - client - .getActivity(r -> r.activityId("https://example.com/activity/simplestatement")) - .block(); + client.getActivity(r -> r.activityId("https://example.com/activity/simplestatement")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); } - + @Test void whenGettingActivityThenPathIsExpected() throws InterruptedException { @@ -1705,7 +1706,7 @@ void whenGettingActivityThenPathIsExpected() throws InterruptedException { .getActivity(r -> r.activityId(URI.create("https://example.com/activity/simplestatement"))) .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -1722,7 +1723,7 @@ void whenGettingActivityThenBodyIsInstanceOfActivity() throws InterruptedExcepti .addHeader("Content-Type", "application/json; charset=utf-8")); // When Getting Activity - var response = client + final var response = client .getActivity(r -> r.activityId(URI.create("https://example.com/activity/simplestatement"))) .block(); @@ -1740,7 +1741,7 @@ void whenGettingAgentsThenMethodIsGet() throws InterruptedException { // When Getting Agents client.getAgents(r -> r.agent(a -> a.mbox("mailto:another@example.com"))).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1754,11 +1755,11 @@ void whenGettingAgentsThenPathIsExpected() throws InterruptedException { // When Getting Agents client.getAgents(r -> r.agent(a -> a.mbox("mailto:another@example.com"))).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected - assertThat(recordedRequest.getPath(), - is("/agents?agent=%7B%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); + assertThat(recordedRequest.getPath(), is( + "/agents?agent=%7B%22objectType%22%3A%22Agent%22%2C%22mbox%22%3A%22mailto%3Aanother%40example.com%22%7D")); } @Test @@ -1771,8 +1772,8 @@ void whenGettingAgentsThenBodyIsInstanceOfPerson() throws InterruptedException { .addHeader("Content-Type", "application/json; charset=utf-8")); // When Getting Agents - var response = - client.getAgents(r -> r.agent(a -> a.mbox("mailto:another@example.com"))).block(); + final var response = client.getAgents(r -> r.agent(a -> a.mbox("mailto:another@example.com"))) + .block(); // Then Body Is Instance Of Activity assertThat(response.getBody(), instanceOf(Person.class)); @@ -1792,7 +1793,7 @@ void whenGettingAboutThenMethodIsGet() throws InterruptedException { // When Getting About client.getAbout().block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1810,7 +1811,7 @@ void whenGettingAboutThenPathIsExpected() throws InterruptedException { // When Getting About client.getAbout().block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is("/about")); @@ -1826,14 +1827,12 @@ void whenGettingAboutThenBodyIsInstanceOfAbout() throws InterruptedException { .addHeader("Content-Type", "application/json; charset=utf-8")); // When Getting About - var response = client.getAbout().block(); + final var response = client.getAbout().block(); // Then Body Is Instance Of About assertThat(response.getBody(), instanceOf(About.class)); } - - // Get Single Activity Profile @Test @@ -1846,7 +1845,7 @@ void whenGettingASingleActivityProfileThenMethodIsGet() throws InterruptedExcept .profileId("bookmark"), String.class).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -1862,7 +1861,7 @@ void whenGettingASingleActivityProfileThenPathIsExpected() throws InterruptedExc .profileId("bookmark"), String.class).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( @@ -1878,7 +1877,7 @@ void givenActivityProfileContentTypeIsTextPlainWhenGettingActivityProfileThenBod .addHeader("Content-Type", "text/plain; charset=utf-8")); // When Getting ActivityProfile - ResponseEntity response = client + final ResponseEntity response = client .getActivityProfile(r -> r.activityId("https://example.com/activity/1") .profileId("bookmark"), String.class) @@ -1898,7 +1897,7 @@ void givenActivityProfileContentTypeIsTextPlainWhenGettingActivityProfileThenBod .addHeader("Content-Type", "text/plain; charset=utf-8")); // When Getting ActivityProfile - ResponseEntity response = client + final ResponseEntity response = client .getActivityProfile(r -> r.activityId("https://example.com/activity/1") .profileId("bookmark"), String.class) @@ -1925,7 +1924,7 @@ void whenPostingASingleActivityProfileThenMethodIsPost() throws InterruptedExcep .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("POST")); @@ -1945,7 +1944,7 @@ void whenPostingASingleActivityProfileThenPathIsExpected() throws InterruptedExc .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( @@ -1969,7 +1968,7 @@ void whenPostingASingleActivityProfileWithContentTypeTextPlainThenContentTypeHea .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Text Plain assertThat(recordedRequest.getHeader("content-type"), is("text/plain")); @@ -1990,7 +1989,7 @@ void whenPostingASingleActivityProfileWithoutContentTypeThenContentTypeHeaderIsA .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -2012,7 +2011,7 @@ void whenPuttingASingleActivityProfileThenMethodIsPut() throws InterruptedExcept .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Post assertThat(recordedRequest.getMethod(), is("PUT")); @@ -2032,7 +2031,7 @@ void whenPuttingASingleActivityProfileThenPathIsExpected() throws InterruptedExc .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( @@ -2056,7 +2055,7 @@ void whenPuttingASingleActivityProfileWithContentTypeTextPlainThenContentTypeHea .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Text Plain assertThat(recordedRequest.getHeader("content-type"), is("text/plain")); @@ -2077,7 +2076,7 @@ void whenPuttingASingleActivityProfileWithoutContentTypeThenContentTypeHeaderIsA .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Content Type Header Is Application Json assertThat(recordedRequest.getHeader("content-type"), is("application/json")); @@ -2095,7 +2094,7 @@ void whenDeletingASingleActivityProfileThenMethodIsDelete() throws InterruptedEx .profileId("bookmark")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Delete assertThat(recordedRequest.getMethod(), is("DELETE")); @@ -2111,7 +2110,7 @@ void whenDeletingASingleActivityProfileThenPathIsExpected() throws InterruptedEx .profileId("bookmark")).block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( @@ -2131,7 +2130,7 @@ void whenGettingActivityProfilesWithSinceParameterThenMethodIsGet() throws Inter .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Method Is Get assertThat(recordedRequest.getMethod(), is("GET")); @@ -2151,7 +2150,7 @@ void whenGettingActivityProfilesWithSinceParameterThenPathIsExpected() .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), is( @@ -2170,7 +2169,7 @@ void whenGettingActivityProfilesWithoutSinceParameterThenPathIsExpected() .block(); - RecordedRequest recordedRequest = mockWebServer.takeRequest(); + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); // Then Path Is Expected assertThat(recordedRequest.getPath(), @@ -2180,8 +2179,8 @@ void whenGettingActivityProfilesWithoutSinceParameterThenPathIsExpected() @Getter private static class SamplePerson { - private String firstName; - private String lastName; + private final String firstName; + private final String lastName; public SamplePerson(String firstName, String lastName) { super(); diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/Activity.java b/xapi-model/src/main/java/dev/learning/xapi/model/Activity.java index 69956c8c..6e7ead1d 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/Activity.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/Activity.java @@ -10,7 +10,6 @@ import java.util.function.Consumer; import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.Builder.Default; import lombok.EqualsAndHashCode; import lombok.Value; @@ -29,9 +28,6 @@ @EqualsAndHashCode(exclude = "definition") public class Activity implements StatementObject, SubStatementObject { - @Default - private final ObjectType objectType = ObjectType.ACTIVITY; - /** * An identifier for a single unique Activity. */ @@ -53,7 +49,6 @@ public class Activity implements StatementObject, SubStatementObject { */ public Activity(String id) { - this.objectType = ObjectType.ACTIVITY; this.id = URI.create(id); this.definition = null; } diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/Actor.java b/xapi-model/src/main/java/dev/learning/xapi/model/Actor.java index a6c86dbd..9da1bedf 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/Actor.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/Actor.java @@ -32,8 +32,8 @@ @ToString @NoArgsConstructor @EqualsAndHashCode(exclude = "name") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "objectType", visible = false, - defaultImpl = Agent.class, include = As.EXISTING_PROPERTY) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "objectType", + defaultImpl = Agent.class, include = As.PROPERTY) @JsonSubTypes({@JsonSubTypes.Type(value = Agent.class, name = "Agent"), @JsonSubTypes.Type(value = Agent.class, name = "Person"), @JsonSubTypes.Type(value = Group.class, name = "Group")}) diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/Agent.java b/xapi-model/src/main/java/dev/learning/xapi/model/Agent.java index 17558360..c50f7b5f 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/Agent.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/Agent.java @@ -5,10 +5,9 @@ package dev.learning.xapi.model; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.SuperBuilder; @@ -21,16 +20,12 @@ */ @Getter @SuperBuilder -@AllArgsConstructor +@NoArgsConstructor @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @JsonIgnoreProperties(value = {"firstName", "lastName"}) -@JsonSubTypes({@JsonSubTypes.Type(value = Agent.class, name = "Agent"), - @JsonSubTypes.Type(value = Agent.class, name = "Person")}) public class Agent extends Actor { - private ObjectType objectType; - // **Warning** do not add fields that are not required by the xAPI specification. /** diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/Group.java b/xapi-model/src/main/java/dev/learning/xapi/model/Group.java index 6e9f1d25..c7c3cf79 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/Group.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/Group.java @@ -5,16 +5,12 @@ package dev.learning.xapi.model; import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import jakarta.validation.Valid; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Consumer; import lombok.AllArgsConstructor; -import lombok.Builder.Default; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -32,14 +28,8 @@ @AllArgsConstructor @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "objectType", visible = true, - include = As.EXISTING_PROPERTY) -@JsonSubTypes({@JsonSubTypes.Type(value = Group.class, name = "Group")}) public class Group extends Actor { - @Default - private final ObjectType objectType = ObjectType.GROUP; - /** * The members of this Group. */ diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/StatementObject.java b/xapi-model/src/main/java/dev/learning/xapi/model/StatementObject.java index 14875d22..ce38625a 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/StatementObject.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/StatementObject.java @@ -20,7 +20,7 @@ */ @JsonInclude(Include.NON_EMPTY) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "objectType", defaultImpl = Activity.class, - visible = true, include = As.EXISTING_PROPERTY) + include = As.PROPERTY) @JsonSubTypes({@JsonSubTypes.Type(value = Activity.class, name = "Activity"), @JsonSubTypes.Type(value = Agent.class, name = "Agent"), @JsonSubTypes.Type(value = Group.class, name = "Group"), diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/StatementReference.java b/xapi-model/src/main/java/dev/learning/xapi/model/StatementReference.java index 551c1841..ebe4b071 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/StatementReference.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/StatementReference.java @@ -4,11 +4,9 @@ package dev.learning.xapi.model; -import com.fasterxml.jackson.annotation.JsonTypeInfo; import jakarta.validation.constraints.NotNull; import java.util.UUID; import lombok.Builder; -import lombok.Builder.Default; import lombok.Value; /** @@ -22,12 +20,8 @@ */ @Value @Builder -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "objectType") public class StatementReference implements StatementObject, SubStatementObject { - @Default - private final ObjectType objectType = ObjectType.STATEMENTREF; - /** * The UUID of a Statement. */ diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/SubStatement.java b/xapi-model/src/main/java/dev/learning/xapi/model/SubStatement.java index c9c1c2e9..d5e10f07 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/SubStatement.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/SubStatement.java @@ -4,13 +4,11 @@ package dev.learning.xapi.model; -import com.fasterxml.jackson.annotation.JsonTypeInfo; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import java.time.Instant; import java.util.function.Consumer; import lombok.Builder; -import lombok.Builder.Default; import lombok.EqualsAndHashCode; import lombok.Value; @@ -24,13 +22,9 @@ */ @Value @Builder -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "objectType") @EqualsAndHashCode(exclude = {"timestamp", "attachments"}) public class SubStatement implements StatementObject { - @Default - private final ObjectType objectType = ObjectType.SUBSTATEMENT; - /** * Whom the Statement is about, as an Agent or Group Object. */ diff --git a/xapi-model/src/main/java/dev/learning/xapi/model/SubStatementObject.java b/xapi-model/src/main/java/dev/learning/xapi/model/SubStatementObject.java index 53835e04..31baa07b 100644 --- a/xapi-model/src/main/java/dev/learning/xapi/model/SubStatementObject.java +++ b/xapi-model/src/main/java/dev/learning/xapi/model/SubStatementObject.java @@ -24,7 +24,7 @@ */ @JsonInclude(Include.NON_EMPTY) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "objectType", defaultImpl = Activity.class, - visible = true, include = As.EXISTING_PROPERTY) + include = As.PROPERTY) @JsonSubTypes({@JsonSubTypes.Type(value = Activity.class, name = "Activity"), @JsonSubTypes.Type(value = Agent.class, name = "Agent"), @JsonSubTypes.Type(value = Group.class, name = "Group"), diff --git a/xapi-model/src/test/java/dev/learning/xapi/model/ActivityTests.java b/xapi-model/src/test/java/dev/learning/xapi/model/ActivityTests.java index b3be7a20..f30d4f41 100644 --- a/xapi-model/src/test/java/dev/learning/xapi/model/ActivityTests.java +++ b/xapi-model/src/test/java/dev/learning/xapi/model/ActivityTests.java @@ -41,19 +41,6 @@ void whenDeserializingActivityThenResultIsInstanceOfActivity() throws Exception } - @Test - void whenDeserializingActivityThenObjectTypeIsExpected() throws Exception { - - final File file = ResourceUtils.getFile("classpath:activity/activity_with_object_type.json"); - - // When Deserializing Activity - final Activity result = objectMapper.readValue(file, Activity.class); - - // Then Object Type Is Expected - assertThat(result.getObjectType(), is(ObjectType.ACTIVITY)); - - } - @Test void whenDeserializingActivityThenIdIsExpected() throws Exception { @@ -113,8 +100,6 @@ void whenCallingToStringThenResultIsExpected() throws IOException { final Activity activity = Activity.builder() - .objectType(ObjectType.ACTIVITY) - .id(URI.create("http://www.example.co.uk/exampleactivity")) .definition(d -> d.addDescription(Locale.US, @@ -127,7 +112,7 @@ void whenCallingToStringThenResultIsExpected() throws IOException { // Then Result Is Expected assertThat(result, is( - "Activity(objectType=ACTIVITY, id=http://www.example.co.uk/exampleactivity, definition=ActivityDefinition(name=null, description={en_US=A simple Experience API statement. Note that the LRS does not need to have any prior information about the Actor (learner), the verb, or the Activity/object.}, type=null, moreInfo=null, interactionType=null, correctResponsesPattern=null, choices=null, scale=null, source=null, target=null, steps=null, extensions=null))")); + "Activity(id=http://www.example.co.uk/exampleactivity, definition=ActivityDefinition(name=null, description={en_US=A simple Experience API statement. Note that the LRS does not need to have any prior information about the Actor (learner), the verb, or the Activity/object.}, type=null, moreInfo=null, interactionType=null, correctResponsesPattern=null, choices=null, scale=null, source=null, target=null, steps=null, extensions=null))")); } diff --git a/xapi-model/src/test/java/dev/learning/xapi/model/ContextActivitiesTests.java b/xapi-model/src/test/java/dev/learning/xapi/model/ContextActivitiesTests.java index b08e4051..95eecf32 100644 --- a/xapi-model/src/test/java/dev/learning/xapi/model/ContextActivitiesTests.java +++ b/xapi-model/src/test/java/dev/learning/xapi/model/ContextActivitiesTests.java @@ -131,7 +131,7 @@ void whenCallingToStringThenResultIsExpected() throws IOException { // Then Result Is Expected assertThat(result, is( - "ContextActivities(parent=[Activity(objectType=ACTIVITY, id=https://example.com/activity/1, definition=null)], grouping=[Activity(objectType=ACTIVITY, id=https://example.com/activity/2, definition=null)], category=[Activity(objectType=ACTIVITY, id=https://example.com/activity/3, definition=null)], other=[Activity(objectType=ACTIVITY, id=https://example.com/activity/4, definition=null)])")); + "ContextActivities(parent=[Activity(id=https://example.com/activity/1, definition=null)], grouping=[Activity(id=https://example.com/activity/2, definition=null)], category=[Activity(id=https://example.com/activity/3, definition=null)], other=[Activity(id=https://example.com/activity/4, definition=null)])")); } diff --git a/xapi-model/src/test/java/dev/learning/xapi/model/ContextTests.java b/xapi-model/src/test/java/dev/learning/xapi/model/ContextTests.java index e54ff72f..1e834553 100644 --- a/xapi-model/src/test/java/dev/learning/xapi/model/ContextTests.java +++ b/xapi-model/src/test/java/dev/learning/xapi/model/ContextTests.java @@ -268,7 +268,7 @@ void whenCallingToStringThenResultIsExpected() throws IOException { // Then Result Is Expected assertThat(result, is( - "Context(registration=1d527164-ed0d-4b1d-9f9b-39aab0e4a089, instructor=Agent(super=Actor(name=Andrew Downes, mbox=mailto:andrew@example.co.uk, mboxSha1sum=null, openid=null, account=null), objectType=null), team=Group(super=Actor(name=Example Group, mbox=null, mboxSha1sum=null, openid=null, account=null), objectType=GROUP, member=null), contextActivities=ContextActivities(parent=[Activity(objectType=ACTIVITY, id=https://example.com/activity/1, definition=null)], grouping=[Activity(objectType=ACTIVITY, id=https://example.com/activity/2, definition=null)], category=[Activity(objectType=ACTIVITY, id=https://example.com/activity/3, definition=null)], other=[Activity(objectType=ACTIVITY, id=https://example.com/activity/4, definition=null)]), revision=revision, platform=platform, language=en, statement=StatementReference(objectType=null, id=e9b6b9ed-ef48-4986-9b86-2ef697578bf7), extensions={http://url=www.example.com})")); + "Context(registration=1d527164-ed0d-4b1d-9f9b-39aab0e4a089, instructor=Agent(super=Actor(name=Andrew Downes, mbox=mailto:andrew@example.co.uk, mboxSha1sum=null, openid=null, account=null)), team=Group(super=Actor(name=Example Group, mbox=null, mboxSha1sum=null, openid=null, account=null), member=null), contextActivities=ContextActivities(parent=[Activity(id=https://example.com/activity/1, definition=null)], grouping=[Activity(id=https://example.com/activity/2, definition=null)], category=[Activity(id=https://example.com/activity/3, definition=null)], other=[Activity(id=https://example.com/activity/4, definition=null)]), revision=revision, platform=platform, language=en, statement=StatementReference(id=e9b6b9ed-ef48-4986-9b86-2ef697578bf7), extensions={http://url=www.example.com})")); } diff --git a/xapi-model/src/test/java/dev/learning/xapi/model/GroupTests.java b/xapi-model/src/test/java/dev/learning/xapi/model/GroupTests.java index cd40484e..0765f1ea 100644 --- a/xapi-model/src/test/java/dev/learning/xapi/model/GroupTests.java +++ b/xapi-model/src/test/java/dev/learning/xapi/model/GroupTests.java @@ -102,7 +102,7 @@ void whenCallingToStringThenResultIsExpected() throws IOException { // Then Result Is Expected assertThat(result, is( - "Group(super=Actor(name=Example Group, mbox=null, mboxSha1sum=null, openid=null, account=Account(homePage=http://example.com/homePage, name=GroupAccount)), objectType=GROUP, member=[Agent(super=Actor(name=Member 1, mbox=mailto:member1@example.com, mboxSha1sum=null, openid=null, account=null), objectType=null), Agent(super=Actor(name=Member 2, mbox=null, mboxSha1sum=null, openid=https://example.com/openId, account=null), objectType=null)])")); + "Group(super=Actor(name=Example Group, mbox=null, mboxSha1sum=null, openid=null, account=Account(homePage=http://example.com/homePage, name=GroupAccount)), member=[Agent(super=Actor(name=Member 1, mbox=mailto:member1@example.com, mboxSha1sum=null, openid=null, account=null)), Agent(super=Actor(name=Member 2, mbox=null, mboxSha1sum=null, openid=https://example.com/openId, account=null))])")); } diff --git a/xapi-model/src/test/java/dev/learning/xapi/model/StatementReferenceTest.java b/xapi-model/src/test/java/dev/learning/xapi/model/StatementReferenceTest.java index bf2e4d4c..4a04c3ba 100644 --- a/xapi-model/src/test/java/dev/learning/xapi/model/StatementReferenceTest.java +++ b/xapi-model/src/test/java/dev/learning/xapi/model/StatementReferenceTest.java @@ -91,7 +91,7 @@ void whenCallingToStringThenResultIsExpected() throws IOException { // Then Result Is Expected assertThat(result, - is("StatementReference(objectType=null, id=099bbde8-780e-483f-8181-128393db0f53)")); + is("StatementReference(id=099bbde8-780e-483f-8181-128393db0f53)")); } diff --git a/xapi-model/src/test/java/dev/learning/xapi/model/SubStatementTests.java b/xapi-model/src/test/java/dev/learning/xapi/model/SubStatementTests.java index 1fb74bcc..47f6214c 100644 --- a/xapi-model/src/test/java/dev/learning/xapi/model/SubStatementTests.java +++ b/xapi-model/src/test/java/dev/learning/xapi/model/SubStatementTests.java @@ -350,7 +350,7 @@ void whenCallingToStringThenResultIsExpected() throws IOException { // Then Result Is Expected assertThat(result, is( - "SubStatement(objectType=null, actor=Agent(super=Actor(name=null, mbox=mailto:agent@example.com, mboxSha1sum=null, openid=null, account=null), objectType=null), verb=Verb(id=http://example.com/confirmed, display={en=confirmed}), object=StatementReference(objectType=STATEMENTREF, id=9e13cefd-53d3-4eac-b5ed-2cf6693903bb), result=Result(score=Score(scaled=1.0, raw=1.0, min=0.0, max=5.0), success=true, completion=true, response=test, duration=P1D, extensions=null), context=Context(registration=6d969975-8d7e-4506-ac19-877c57f2921a, instructor=Agent(super=Actor(name=null, mbox=mailto:agent@example.com, mboxSha1sum=null, openid=null, account=null), objectType=null), team=Group(super=Actor(name=Example Group, mbox=null, mboxSha1sum=null, openid=null, account=null), objectType=GROUP, member=null), contextActivities=ContextActivities(parent=[Activity(objectType=ACTIVITY, id=http://www.example.co.uk/exampleactivity, definition=null)], grouping=[Activity(objectType=ACTIVITY, id=http://www.example.co.uk/exampleactivity, definition=null)], category=[Activity(objectType=ACTIVITY, id=http://www.example.co.uk/exampleactivity, definition=null)], other=[Activity(objectType=ACTIVITY, id=http://www.example.co.uk/exampleactivity, definition=null)]), revision=revision, platform=platform, language=en, statement=StatementReference(objectType=null, id=9e13cefd-53d3-4eac-b5ed-2cf6693903bb), extensions={http://url=www.example.com}), timestamp=2015-11-18T11:17:00Z, attachments=[Attachment(usageType=http://example.com, display={en=value}, description={en=value}, contentType=file, length=123, sha2=123, fileUrl=http://example.com)])")); + "SubStatement(actor=Agent(super=Actor(name=null, mbox=mailto:agent@example.com, mboxSha1sum=null, openid=null, account=null)), verb=Verb(id=http://example.com/confirmed, display={en=confirmed}), object=StatementReference(id=9e13cefd-53d3-4eac-b5ed-2cf6693903bb), result=Result(score=Score(scaled=1.0, raw=1.0, min=0.0, max=5.0), success=true, completion=true, response=test, duration=P1D, extensions=null), context=Context(registration=6d969975-8d7e-4506-ac19-877c57f2921a, instructor=Agent(super=Actor(name=null, mbox=mailto:agent@example.com, mboxSha1sum=null, openid=null, account=null)), team=Group(super=Actor(name=Example Group, mbox=null, mboxSha1sum=null, openid=null, account=null), member=null), contextActivities=ContextActivities(parent=[Activity(id=http://www.example.co.uk/exampleactivity, definition=null)], grouping=[Activity(id=http://www.example.co.uk/exampleactivity, definition=null)], category=[Activity(id=http://www.example.co.uk/exampleactivity, definition=null)], other=[Activity(id=http://www.example.co.uk/exampleactivity, definition=null)]), revision=revision, platform=platform, language=en, statement=StatementReference(id=9e13cefd-53d3-4eac-b5ed-2cf6693903bb), extensions={http://url=www.example.com}), timestamp=2015-11-18T11:17:00Z, attachments=[Attachment(usageType=http://example.com, display={en=value}, description={en=value}, contentType=file, length=123, sha2=123, fileUrl=http://example.com)])")); } diff --git a/xapi-model/src/test/resources/agent/agent_with_account.json b/xapi-model/src/test/resources/agent/agent_with_account.json index 9213e34e..50a582c7 100644 --- a/xapi-model/src/test/resources/agent/agent_with_account.json +++ b/xapi-model/src/test/resources/agent/agent_with_account.json @@ -1,4 +1,5 @@ { + "objectType": "Agent", "name": "A N Other", "account": { "name": "another", diff --git a/xapi-model/src/test/resources/agent/agent_with_mbox.json b/xapi-model/src/test/resources/agent/agent_with_mbox.json index bd7805f0..61261de5 100644 --- a/xapi-model/src/test/resources/agent/agent_with_mbox.json +++ b/xapi-model/src/test/resources/agent/agent_with_mbox.json @@ -1,4 +1,5 @@ { + "objectType": "Agent", "name": "A N Other", "mbox": "mailto:other@example.com" } diff --git a/xapi-model/src/test/resources/agent/agent_with_mbox_sha1sum.json b/xapi-model/src/test/resources/agent/agent_with_mbox_sha1sum.json index 2b4f2421..d2386a6d 100644 --- a/xapi-model/src/test/resources/agent/agent_with_mbox_sha1sum.json +++ b/xapi-model/src/test/resources/agent/agent_with_mbox_sha1sum.json @@ -1,4 +1,5 @@ { + "objectType": "Agent", "name": "A N Other", "mbox_sha1sum": "1234" } diff --git a/xapi-model/src/test/resources/agent/agent_with_name.json b/xapi-model/src/test/resources/agent/agent_with_name.json index bd7805f0..61261de5 100644 --- a/xapi-model/src/test/resources/agent/agent_with_name.json +++ b/xapi-model/src/test/resources/agent/agent_with_name.json @@ -1,4 +1,5 @@ { + "objectType": "Agent", "name": "A N Other", "mbox": "mailto:other@example.com" } diff --git a/xapi-model/src/test/resources/agent/agent_with_openid.json b/xapi-model/src/test/resources/agent/agent_with_openid.json index cc967d90..cbfed446 100644 --- a/xapi-model/src/test/resources/agent/agent_with_openid.json +++ b/xapi-model/src/test/resources/agent/agent_with_openid.json @@ -1,4 +1,5 @@ { + "objectType": "Agent", "name": "A N Other", "openid": "1234" } diff --git a/xapi-model/src/test/resources/context/context.json b/xapi-model/src/test/resources/context/context.json index 7e646aff..06d476a4 100644 --- a/xapi-model/src/test/resources/context/context.json +++ b/xapi-model/src/test/resources/context/context.json @@ -4,6 +4,7 @@ "platform": "platform", "language": "en", "instructor": { + "objectType": "Agent", "name": "Andrew Downes", "mbox": "mailto:andrew@example.co.uk" }, diff --git a/xapi-model/src/test/resources/context/context_with_group_instructor.json b/xapi-model/src/test/resources/context/context_with_group_instructor.json index 1e69c06e..8d11dc3d 100644 --- a/xapi-model/src/test/resources/context/context_with_group_instructor.json +++ b/xapi-model/src/test/resources/context/context_with_group_instructor.json @@ -3,13 +3,15 @@ "objectType":"Group", "member":[ { + "objectType": "Agent", "name":"Leader 1", "mbox":"mailto:leader1@example.com" }, { + "objectType": "Agent", "name":"Leader 2", "mbox":"mailto:leader2@example.com" } ] } -} \ No newline at end of file +} diff --git a/xapi-model/src/test/resources/group/group.json b/xapi-model/src/test/resources/group/group.json index 3d7463ab..4cc913f6 100644 --- a/xapi-model/src/test/resources/group/group.json +++ b/xapi-model/src/test/resources/group/group.json @@ -7,10 +7,12 @@ "objectType": "Group", "member": [ { + "objectType": "Agent", "name": "Member 1", "mbox": "mailto:member1@example.com" }, { + "objectType": "Agent", "name": "Member 2", "openid": "https://example.com/openId" }