Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@ void whenBuildingDeleteActivityProfileRequestWithAllParametersThenNoExceptionIsT

}

@Test
void whenBuildingDeleteActivityProfileRequestWithoutRegistrationThenNoExceptionIsThrown() {

// When Building DeleteActivityProfileRequest Without Registration
Builder<?, ?> builder = DeleteActivityProfileRequest.builder()

.activityId(URI.create("https://example.com/activity/1"))

.profileId("bookmark");

// Then No Exception Is Thrown
assertDoesNotThrow(builder::build);

}

@Test
void whenBuildingDeleteActivityProfileRequestWithoutActivityIdThenExceptionIsThrown() {

Expand Down Expand Up @@ -105,29 +90,4 @@ void givenDeleteActivityProfileRequestWithAllParametersWhenGettingURLThenResultI

}

@Test
void givenDeleteActivityProfileRequestWithoutRegistrationWhenGettingURLThenResultIsExpected() {

// Given DeleteActivityProfileRequest Without Registration
DeleteActivityProfileRequest request = DeleteActivityProfileRequest.builder()

.activityId(URI.create("https://example.com/activity/1"))

.profileId("bookmark")

.build();

Map<String, Object> queryParams = new HashMap<>();

// When Getting URL
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/profile?activityId=https%3A%2F%2Fexample.com%2Factivity%2F1&profileId=bookmark")));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ void givenApiResponseIsEmptyWhenPostingStatementThenMissingResponseBodyException
.definition(d -> d.addName(Locale.ENGLISH, "Simple Statement")))));

// Then MissingResponseBodyException Is Thrown
assertThrows(MissingResponseBodyException.class, () -> response.block());
assertThrows(MissingResponseBodyException.class, response::block);

}

Expand All @@ -418,7 +418,7 @@ void givenApiResponseIsBadRequestWhenPostingStatementThenBadRequestIsThrown() {
.definition(d -> d.addName(Locale.ENGLISH, "Simple Statement")))));

// Then BadRequest Is Thrown
assertThrows(BadRequest.class, () -> response.block());
assertThrows(BadRequest.class, response::block);

}

Expand All @@ -438,7 +438,7 @@ void givenApiResponseIsInternalServerErrorWhenPostingStatementThenInternalServer
.definition(d -> d.addName(Locale.ENGLISH, "Simple Statement")))));

// Then InternalServerError Is Thrown
assertThrows(InternalServerError.class, () -> response.block());
assertThrows(InternalServerError.class, response::block);

}

Expand Down Expand Up @@ -512,14 +512,14 @@ void whenGettingVoidedStatementWithAttachmentsThenPathIsExpected() throws Interr
mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK"));

// When Getting Voided Statement With Attachments
client.getStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6").attachments(true))
client.getVoidedStatement(r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6").attachments(true))
.block();

final var recordedRequest = mockWebServer.takeRequest();

// Then Path Is Expected
assertThat(recordedRequest.getPath(),
is("/statements?statementId=4df42866-40e7-45b6-bf7c-8d5fccbdccd6&attachments=true"));
is("/statements?voidedStatementId=4df42866-40e7-45b6-bf7c-8d5fccbdccd6&attachments=true"));
}

@Test
Expand All @@ -530,15 +530,15 @@ void whenGettingVoidedStatementWithCanonicalFormatThenPathIsExpected()

// When Getting Voided Statement With Canonical Format
client
.getStatement(
.getVoidedStatement(
r -> r.id("4df42866-40e7-45b6-bf7c-8d5fccbdccd6").format(StatementFormat.CANONICAL))
.block();

final var recordedRequest = mockWebServer.takeRequest();

// Then Path Is Expected
assertThat(recordedRequest.getPath(),
is("/statements?statementId=4df42866-40e7-45b6-bf7c-8d5fccbdccd6&format=canonical"));
is("/statements?voidedStatementId=4df42866-40e7-45b6-bf7c-8d5fccbdccd6&format=canonical"));
}

// Get Statements
Expand Down Expand Up @@ -791,8 +791,7 @@ void whenGettingASingleStateWithoutRegistrationThenPathIsExpected() throws Inter
}

@Test
void givenStateContentTypeIsTextPlainWhenGettingStateThenBodyIsInstanceOfString()
throws InterruptedException {
void givenStateContentTypeIsTextPlainWhenGettingStateThenBodyIsInstanceOfString() {

// Given State Content Type Is Text Plain
mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK").setBody("Hello World!")
Expand All @@ -814,8 +813,7 @@ void givenStateContentTypeIsTextPlainWhenGettingStateThenBodyIsInstanceOfString(
}

@Test
void givenStateContentTypeIsTextPlainWhenGettingStateThenBodyIsExpected()
throws InterruptedException {
void givenStateContentTypeIsTextPlainWhenGettingStateThenBodyIsExpected() {

// Given State Content Type Is Text Plain
mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK").setBody("Hello World!")
Expand Down Expand Up @@ -1304,8 +1302,7 @@ void whenGettingMultipleStatesWithoutRegistrationThenPathIsExpected()
}

@Test
void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsInstanceOfStringArray()
throws InterruptedException {
void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsInstanceOfStringArray() {

// Given Multiple States Exist
mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK")
Expand All @@ -1326,8 +1323,7 @@ void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsInstanceOfString
}

@Test
void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsExpected()
throws InterruptedException {
void givenMultipleStatesExistWhenGettingMultipleStatesThenBodyIsExpected() {

// Given Multiple States Exist
mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK")
Expand Down Expand Up @@ -2002,8 +1998,7 @@ void whenGettingASingleActivityProfileThenPathIsExpected() throws InterruptedExc
}

@Test
void givenActivityProfileContentTypeIsTextPlainWhenGettingActivityProfileThenBodyIsInstanceOfString()
throws InterruptedException {
void givenActivityProfileContentTypeIsTextPlainWhenGettingActivityProfileThenBodyIsInstanceOfString() {

// Given ActivityProfile Content Type Is Text Plain
mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK").setBody("Hello World!")
Expand All @@ -2022,8 +2017,7 @@ void givenActivityProfileContentTypeIsTextPlainWhenGettingActivityProfileThenBod
}

@Test
void givenActivityProfileContentTypeIsTextPlainWhenGettingActivityProfileThenBodyIsExpected()
throws InterruptedException {
void givenActivityProfileContentTypeIsTextPlainWhenGettingActivityProfileThenBodyIsExpected() {

// Given ActivityProfile Content Type Is Text Plain
mockWebServer.enqueue(new MockResponse().setStatus("HTTP/1.1 200 OK").setBody("Hello World!")
Expand Down Expand Up @@ -2363,7 +2357,7 @@ void givenApiResponseIsEmptyWhenGettingStatementIteratorThenMissingResponseBodyE
final var response = client.getStatementIterator();

// Then MissingResponseBodyException Is Thrown
assertThrows(MissingResponseBodyException.class, () -> response.block());
assertThrows(MissingResponseBodyException.class, response::block);

}

Expand Down Expand Up @@ -2490,8 +2484,7 @@ void whenGettingStatementIteratorAndProcessingItAsStreamThenRequestsAreExpected(
}

@Test
void givenEmptyStatementResultWhenGettingStatementIteratorThenHasNextIsFalse()
throws InterruptedException {
void givenEmptyStatementResultWhenGettingStatementIteratorThenHasNextIsFalse() {

// Given Empty StatementResult
final var body = """
Expand All @@ -2514,8 +2507,7 @@ void givenEmptyStatementResultWhenGettingStatementIteratorThenHasNextIsFalse()
}

@Test
void givenEmptyResponseWhenGettingStatementIteratorThenHasNextIsFalse()
throws InterruptedException {
void givenEmptyResponseWhenGettingStatementIteratorThenHasNextIsFalse() {

// Given Empty Response
// This response is technically invalid by the xAPI specification, but we cannot assume
Expand All @@ -2535,8 +2527,7 @@ void givenEmptyResponseWhenGettingStatementIteratorThenHasNextIsFalse()
}

@Test
void givenEmptyResponseWhenGettingStatementIteratorThenNextThrowsAnException()
throws InterruptedException {
void givenEmptyResponseWhenGettingStatementIteratorThenNextThrowsAnException() {

// Given Empty Response
final var body = """
Expand All @@ -2554,7 +2545,7 @@ void givenEmptyResponseWhenGettingStatementIteratorThenNextThrowsAnException()
final var iterator = client.getStatementIterator().block();

// Then Next Throws An Exception
assertThrows(NoSuchElementException.class, () -> iterator.next());
assertThrows(NoSuchElementException.class, iterator::next);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void accept(Builder builder) {
try {
mockWebServer.start();
} catch (final IOException e) {
// Ignore - test will fail if server doesn't start
}
builder.baseUrl(mockWebServer.url("").toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void accept(Builder builder) {
try {
mockWebServer.start();
} catch (final IOException e) {
// Ignore - test will fail if server doesn't start
}
builder.baseUrl(mockWebServer.url("").toString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import dev.learning.xapi.model.validation.constraints.ValidStatementVerb;
import dev.learning.xapi.model.validation.constraints.Variant;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.lang.UnknownClassException;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -162,8 +161,8 @@ public Statement signAndBuild(PrivateKey privateKey) {
claims.put("context", this.context);

try {
final var token = Jwts.builder().setClaims(claims)
.signWith(privateKey, SignatureAlgorithm.RS512).compact();
final var token = Jwts.builder().claims(claims)
.signWith(privateKey, Jwts.SIG.RS512).compact();

addAttachment(a -> a.usageType(URI.create("http://adlnet.gov/expapi/attachments/signature"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -247,8 +246,7 @@ void givenAttachmentWithStringDataWhenGettingSHA2ThenResultIsExpected() {
}

@Test
void givenAttachmentWithBinaryDataWhenGettingSHA2ThenResultIsExpected()
throws FileNotFoundException, IOException {
void givenAttachmentWithBinaryDataWhenGettingSHA2ThenResultIsExpected() throws IOException {

final var data =
Files.readAllBytes(ResourceUtils.getFile("classpath:attachment/example.jpg").toPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ void whenBuildingContextActivitiesWithTwoCategoriesThenCategoryIshasSizeTwo() {
}

@Test
void whenBuildingContextActivitiesWithTwoParentsWithSameIdThenParentIshasSizeTwo()
throws IOException {
void whenBuildingContextActivitiesWithTwoParentsWithSameIdThenParentIshasSizeTwo() {

// When Building ContextActivities With Two Parents With Same Id
final var contextActivities = ContextActivities.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ void givenGroupWithNameAndNoMembersWhenCallingIsAnonymousThenResultIsFalse() {
}

@Test
void givenGroupWithNameAndNullMembersWhenCallingIsAnonymousThenResultIsFalse()
throws IOException {
void givenGroupWithNameAndNullMembersWhenCallingIsAnonymousThenResultIsFalse() {

// Given Group With Name And Null Members
final Group group = Group.builder()
Expand Down Expand Up @@ -194,8 +193,7 @@ void givenGroupWithMboxAndMembersWhenCallingIsAnonymousThenResultIsFalse() {
}

@Test
void givenGroupWithMboxSha1sumAndMembersWhenCallingIsAnonymousThenResultIsFalse()
throws IOException {
void givenGroupWithMboxSha1sumAndMembersWhenCallingIsAnonymousThenResultIsFalse() {

// Given Group With MboxSha1sum And Members
final Group group = Group.builder()
Expand Down
Loading
Loading