Skip to content

Commit

Permalink
chore: pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Jun 5, 2024
1 parent c0b4e2c commit 7469757
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean isHttpsEnabled() {
return httpsEnabled;
}

public boolean isCheckPrefixes() {
public boolean shouldCheckPrefixes() {
return checkPrefixes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public TitaniumJsonLd(Monitor monitor) {
public TitaniumJsonLd(Monitor monitor, JsonLdConfiguration configuration) {
this.monitor = monitor;
this.documentLoader = new CachedDocumentLoader(configuration, monitor);
this.shouldCheckPrefixes = configuration.isCheckPrefixes();
this.shouldCheckPrefixes = configuration.shouldCheckPrefixes();
this.validator = JsonObjectValidator.newValidator()
.verify((path) -> new MissingPrefixes(path, this::getAllPrefixes))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void expand_shouldFail_whenPropertiesWithoutNamespaceAndContextIsMissing() {
}

@Test
void expand_shouldFail_whenMissingRegisteredPrefix() {
void expand_shouldSucceed_whenChecksDisabledOnMissingContext() {
var jsonObject = createObjectBuilder()
.add(JsonLdKeywords.CONTEXT, createObjectBuilder().build())
.add("custom:item", "foo")
Expand All @@ -88,11 +88,11 @@ void expand_shouldFail_whenMissingRegisteredPrefix() {

var expanded = jsonLd.expand(jsonObject);

AbstractResultAssert.assertThat(expanded).isSucceeded();
assertThat(expanded).isSucceeded();
}

@Test
void expand_shouldSucceed_whenMissingRegisteredPrefix() {
void expand_shouldFail_whenMissingContext() {
var jsonObject = createObjectBuilder()
.add(JsonLdKeywords.CONTEXT, createObjectBuilder().build())
.add("custom:item", "foo")
Expand All @@ -103,7 +103,7 @@ void expand_shouldSucceed_whenMissingRegisteredPrefix() {

var expanded = jsonLd.expand(jsonObject);

AbstractResultAssert.assertThat(expanded).isFailed();
assertThat(expanded).isFailed();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

class MissingPrefixesTest {


private final JsonObjectValidator validator = JsonObjectValidator.newValidator()
.verify(path -> new MissingPrefixes(path, () -> Set.of("prefix"))).build();

@Test
void shouldValidateObjectMissingPrefixes_success() {
var input = createObjectBuilder()
Expand All @@ -36,7 +40,7 @@ void shouldValidateObjectMissingPrefixes_success() {
.add("subProperty", ""))
);

var result = JsonObjectValidator.newValidator().verify(path -> new MissingPrefixes(path, () -> Set.of("prefix"))).build().validate(input.build());
var result = validator.validate(input.build());

assertThat(result).isSucceeded();
}
Expand All @@ -49,7 +53,7 @@ void shouldValidateObjectMissingPrefixes_failure() {
.add("subProperty", ""))
);

var result = JsonObjectValidator.newValidator().verify(path -> new MissingPrefixes(path, () -> Set.of("prefix"))).build().validate(input.build());
var result = validator.validate(input.build());

assertThat(result).isFailed().satisfies(failure -> {
assertThat(failure.getViolations()).anySatisfy(violation -> {
Expand All @@ -66,7 +70,7 @@ void shouldValidateMissingPrefixes_whenNestedProperty_failure() {
.add("prefix:subProperty", ""))
);

var result = JsonObjectValidator.newValidator().verify(path -> new MissingPrefixes(path, () -> Set.of("prefix"))).build().validate(input.build());
var result = validator.validate(input.build());

assertThat(result).isFailed().satisfies(failure -> {
assertThat(failure.getViolations()).anySatisfy(violation -> {
Expand All @@ -84,7 +88,7 @@ void shouldValidateNestedMissingPrefixes_whenPrefixedId_failure() {
.add("@id", "prefix:subProperty"))
);

var result = JsonObjectValidator.newValidator().verify("mandatoryObject", path -> new MissingPrefixes(path, () -> Set.of("prefix"))).build().validate(input.build());
var result = validator.validate(input.build());

assertThat(result).isFailed().satisfies(failure -> {
assertThat(failure.getViolations()).anySatisfy(violation -> {
Expand All @@ -102,7 +106,7 @@ void shouldValidateNestedMissingPrefixes_whenPrefixedType_failure() {
.add("@type", createArrayBuilder().add("prefix:subProperty")))
);

var result = JsonObjectValidator.newValidator().verify("mandatoryObject", path -> new MissingPrefixes(path, () -> Set.of("prefix"))).build().validate(input.build());
var result = validator.validate(input.build());

assertThat(result).isFailed().satisfies(failure -> {
assertThat(failure.getViolations()).anySatisfy(violation -> {
Expand Down

0 comments on commit 7469757

Please sign in to comment.