Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add credits to collection #55

Merged
merged 1 commit into from
Jun 17, 2024
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 @@ -98,6 +98,10 @@ default <D extends StacCollectionModel> Collection getCollection(D m, String hos
collection.getProperties().put(CollectionProperty.STATUS, m.getSummaries().getStatus());
}

if (m.getSummaries() != null && m.getSummaries().getCredits() != null) {
collection.getProperties().put(CollectionProperty.CREDITS, m.getSummaries().getCredits());
vietnguyengit marked this conversation as resolved.
Show resolved Hide resolved
}

return collection;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class SummariesModel {
protected int score;
protected String status;
protected List<String> credits;

// for testing usage
public SummariesModel(int score, String status) {
public SummariesModel(int score, String status, List<String> credits) {
this.score = score;
this.status = status;
this.credits = credits;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

@Getter
public enum CollectionProperty {
STATUS("status");
STATUS("status"),
CREDITS("credits");



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class StacToCollectionTest {
Expand Down Expand Up @@ -38,13 +40,16 @@ public void verifyBBoxEmptyOrNullWorks() {
public void verifyAddingPropertyWorks() {
StacToCollection stacToCollection = new StacToCollectionImpl();

List<String> credits = Arrays.asList("credit1", "credit2");

StacCollectionModel model = StacCollectionModel
.builder()
.summaries(new SummariesModel(0, "Completed"))
.summaries(new SummariesModel(0, "Completed", credits))
.build();

// Should not throw null pointer
ExtendedCollection collection = (ExtendedCollection) stacToCollection.convert(model);
Assertions.assertEquals("Completed", collection.getProperties().get(CollectionProperty.STATUS));
Assertions.assertEquals(credits, collection.getProperties().get(CollectionProperty.CREDITS));
}
}
Loading