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 @@ -70,6 +70,7 @@ public MetadataField extractField(MetadataFieldPath path) {
.name("Classification")
.label("Default record classification")
.build();
default -> throw new IllegalArgumentException("Path not supported in definition context: " + path);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public enum Metadata {
STATE("[state]"),
CLASSIFICATION("[classification]"),
CREATED_AT("[createdAt]"),
LAST_MODIFIED_AT("[lastModifiedAt]");
LAST_MODIFIED_AT("[lastModifiedAt]"),
// CaseLink metadata
SOURCE_FIELD_PATH("[sourceFieldPath]");

private final String path;

Expand All @@ -37,6 +39,7 @@ public static Metadata fromPath(@NonNull String path) {
case "classification", "security_classification" -> CLASSIFICATION;
case "createdat", "created", "created_date" -> CREATED_AT;
case "lastmodifiedat", "modified", "last_modified", "last_modified_date" -> LAST_MODIFIED_AT;
case "sourcefieldpath" -> SOURCE_FIELD_PATH;
default -> throw new IllegalArgumentException("Invalid metadata path: " + path);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
import app.quickcase.sdk.spring.definition.model.RecordType;
import app.quickcase.sdk.spring.definition.model.Schema;
import app.quickcase.sdk.spring.path.FieldPath;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;

class DefinitionExtractorTest {

Expand Down Expand Up @@ -138,6 +142,21 @@ void shouldReturnLastModifiedAtField() {
.build()
));
}

@ParameterizedTest
@ValueSource(strings = {
"[sourceFieldPath]"
})
@DisplayName("should throw error for paths not supported in definition context")
void shouldThrowErrorForPathsNotSupported(String path) {
var extractor = new DefinitionExtractor(recordType());
var error = assertThrows(
IllegalArgumentException.class,
() -> extractor.extractField(FieldPath.ofMetadata(path))
);

assertThat(error.getMessage(), equalTo("Path not supported in definition context: " + path));
}
}

@Nested
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/app/quickcase/sdk/spring/metadata/MetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ void shouldReturnCreatedAt(String path) {
void shouldReturnLastModifiedAt(String path) {
assertThat(Metadata.fromPath(path), is(Metadata.LAST_MODIFIED_AT));
}

@ParameterizedTest
@ValueSource(strings = {
"[sourcefieldpath]",
"[SourceFieldPATH]", // Case insensitive
})
@DisplayName("should return sourceFieldPath metadata")
void shouldReturnSourceFieldPath(String path) {
assertThat(Metadata.fromPath(path), is(Metadata.SOURCE_FIELD_PATH));
}
}

}