diff --git a/buildSrc/src/main/groovy/nvadatamodel.java-conventions.gradle b/buildSrc/src/main/groovy/nvadatamodel.java-conventions.gradle index 0fb3a1dc3..08f18cba8 100644 --- a/buildSrc/src/main/groovy/nvadatamodel.java-conventions.gradle +++ b/buildSrc/src/main/groovy/nvadatamodel.java-conventions.gradle @@ -10,7 +10,7 @@ plugins { group 'com.github.bibsysdev' -version '0.19.33' +version '0.20.0' repositories { mavenCentral() diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/PublicationInstance.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/PublicationInstance.java index 17e90f89b..4c7d4addf 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/PublicationInstance.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/PublicationInstance.java @@ -14,14 +14,12 @@ import no.unit.nva.model.instancetypes.book.AcademicMonograph; import no.unit.nva.model.instancetypes.book.BookAbstracts; import no.unit.nva.model.instancetypes.book.BookAnthology; -import no.unit.nva.model.instancetypes.book.BookMonograph; import no.unit.nva.model.instancetypes.book.Encyclopedia; import no.unit.nva.model.instancetypes.book.ExhibitionCatalog; import no.unit.nva.model.instancetypes.book.NonFictionMonograph; import no.unit.nva.model.instancetypes.book.PopularScienceMonograph; import no.unit.nva.model.instancetypes.book.Textbook; import no.unit.nva.model.instancetypes.chapter.AcademicChapter; -import no.unit.nva.model.instancetypes.chapter.ChapterArticle; import no.unit.nva.model.instancetypes.chapter.ChapterConferenceAbstract; import no.unit.nva.model.instancetypes.chapter.ChapterInReport; import no.unit.nva.model.instancetypes.chapter.EncyclopediaChapter; @@ -44,7 +42,6 @@ import no.unit.nva.model.instancetypes.journal.CaseReport; import no.unit.nva.model.instancetypes.journal.ConferenceAbstract; import no.unit.nva.model.instancetypes.journal.FeatureArticle; -import no.unit.nva.model.instancetypes.journal.JournalArticle; import no.unit.nva.model.instancetypes.journal.JournalCorrigendum; import no.unit.nva.model.instancetypes.journal.JournalInterview; import no.unit.nva.model.instancetypes.journal.JournalIssue; @@ -78,7 +75,6 @@ @JsonSubTypes.Type(name = "FeatureArticle", value = FeatureArticle.class), @JsonSubTypes.Type(name = "MovingPicture", value = MovingPicture.class), @JsonSubTypes.Type(name = "PerformingArts", value = PerformingArts.class), - @JsonSubTypes.Type(name = "JournalArticle", value = JournalArticle.class), @JsonSubTypes.Type(name = "AcademicArticle", value = AcademicArticle.class), @JsonSubTypes.Type(name = "AcademicLiteratureReview", value = AcademicLiteratureReview.class), @JsonSubTypes.Type(name = "CaseReport", value = CaseReport.class), @@ -91,7 +87,6 @@ @JsonSubTypes.Type(name = "JournalLeader", value = JournalLeader.class), @JsonSubTypes.Type(name = "JournalReview", value = JournalReview.class), @JsonSubTypes.Type(name = "BookAbstracts", value = BookAbstracts.class), - @JsonSubTypes.Type(name = "BookMonograph", value = BookMonograph.class), @JsonSubTypes.Type(name = "AcademicMonograph", value = AcademicMonograph.class), @JsonSubTypes.Type(name = "PopularScienceMonograph", value = PopularScienceMonograph.class), @JsonSubTypes.Type(name = "Encyclopedia", value = Encyclopedia.class), @@ -108,7 +103,6 @@ @JsonSubTypes.Type(name = "ReportResearch", value = ReportResearch.class), @JsonSubTypes.Type(name = "ReportWorkingPaper", value = ReportWorkingPaper.class), @JsonSubTypes.Type(name = "ReportBookOfAbstract", value = ReportBookOfAbstract.class), - @JsonSubTypes.Type(name = "ChapterArticle", value = ChapterArticle.class), @JsonSubTypes.Type(name = "AcademicChapter", value = AcademicChapter.class), @JsonSubTypes.Type(name = "EncyclopediaChapter", value = EncyclopediaChapter.class), @JsonSubTypes.Type(name = "ExhibitionCatalogChapter", value = ExhibitionCatalogChapter.class), diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/UnconfirmedPublisherMigrator.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/UnconfirmedPublisherMigrator.java deleted file mode 100644 index 88dc05cf0..000000000 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/UnconfirmedPublisherMigrator.java +++ /dev/null @@ -1,18 +0,0 @@ -package no.unit.nva.model.instancetypes.artistic; - -import com.fasterxml.jackson.databind.ObjectMapper; -import no.unit.nva.commons.json.JsonUtils; -import no.unit.nva.model.contexttypes.PublishingHouse; - -import static nva.commons.core.attempt.Try.attempt; - -@Deprecated -public interface UnconfirmedPublisherMigrator { - - ObjectMapper MAPPER = JsonUtils.dtoObjectMapper; - - static PublishingHouse toPublisher(Object candidate) { - var publisherString = attempt(() -> MAPPER.writeValueAsString(candidate)).orElseThrow(); - return attempt(() -> MAPPER.readValue(publisherString, PublishingHouse.class)).orElseThrow(); - } -} diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/Broadcast.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/Broadcast.java index 22669e078..092416338 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/Broadcast.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/Broadcast.java @@ -4,15 +4,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import no.unit.nva.model.contexttypes.PublishingHouse; -import no.unit.nva.model.contexttypes.UnconfirmedPublisher; -import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator; import no.unit.nva.model.time.Instant; import nva.commons.core.JacocoGenerated; import java.util.Objects; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") -public class Broadcast implements MovingPictureOutput, UnconfirmedPublisherMigrator { +public class Broadcast implements MovingPictureOutput { public static final String PUBLISHER_FIELD = "publisher"; public static final String DATE_FIELD = "date"; @@ -24,17 +22,7 @@ public class Broadcast implements MovingPictureOutput, UnconfirmedPublisherMigra @JsonProperty(SEQUENCE_FIELD) private final int sequence; - @Deprecated @JsonCreator - public static Broadcast fromJson(@JsonProperty(PUBLISHER_FIELD) Object publisher, - @JsonProperty(DATE_FIELD) Instant date, - @JsonProperty(SEQUENCE_FIELD) int sequence) { - if (publisher instanceof String) { - return new Broadcast(new UnconfirmedPublisher((String) publisher), date, sequence); - } - return new Broadcast(UnconfirmedPublisherMigrator.toPublisher(publisher), date, sequence); - } - public Broadcast(@JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher, @JsonProperty(DATE_FIELD) Instant date, @JsonProperty(SEQUENCE_FIELD) int sequence) { diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/OtherRelease.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/OtherRelease.java index c74d4941d..da558fc2d 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/OtherRelease.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/film/realization/OtherRelease.java @@ -3,16 +3,15 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import java.util.Objects; import no.unit.nva.model.contexttypes.PublishingHouse; -import no.unit.nva.model.contexttypes.UnconfirmedPublisher; import no.unit.nva.model.contexttypes.place.UnconfirmedPlace; -import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator; import no.unit.nva.model.time.Instant; import nva.commons.core.JacocoGenerated; +import java.util.Objects; + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") -public class OtherRelease implements MovingPictureOutput, UnconfirmedPublisherMigrator { +public class OtherRelease implements MovingPictureOutput { public static final String DESCRIPTION_FIELD = "description"; public static final String PLACE_FIELD = "place"; public static final String PUBLISHER_FIELD = "publisher"; @@ -29,19 +28,7 @@ public class OtherRelease implements MovingPictureOutput, UnconfirmedPublisherMi @JsonProperty(SEQUENCE_FIELD) private final int sequence; - @Deprecated @JsonCreator - public static OtherRelease fromJson(@JsonProperty(DESCRIPTION_FIELD) String description, - @JsonProperty(PLACE_FIELD) UnconfirmedPlace place, - @JsonProperty(PUBLISHER_FIELD) Object publisher, - @JsonProperty(DATE_FIELD) Instant date, - @JsonProperty(SEQUENCE_FIELD) int sequence) { - var publishingHouse = publisher instanceof String - ? new UnconfirmedPublisher((String) publisher) - : UnconfirmedPublisherMigrator.toPublisher(publisher); - return new OtherRelease(description, place, publishingHouse, date, sequence); - } - public OtherRelease(@JsonProperty(DESCRIPTION_FIELD) String description, @JsonProperty(PLACE_FIELD) UnconfirmedPlace place, @JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher, diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/AudioVisualPublication.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/AudioVisualPublication.java index d7f6e272c..2b1936991 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/AudioVisualPublication.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/AudioVisualPublication.java @@ -1,18 +1,18 @@ package no.unit.nva.model.instancetypes.artistic.music; -import static no.unit.nva.model.util.SerializationUtils.nullListAsEmpty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import java.util.List; -import java.util.Objects; import no.unit.nva.model.contexttypes.PublishingHouse; -import no.unit.nva.model.contexttypes.UnconfirmedPublisher; -import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator; import nva.commons.core.JacocoGenerated; +import java.util.List; +import java.util.Objects; + +import static no.unit.nva.model.util.SerializationUtils.nullListAsEmpty; + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") -public class AudioVisualPublication implements MusicPerformanceManifestation, UnconfirmedPublisherMigrator { +public class AudioVisualPublication implements MusicPerformanceManifestation { public static final String MEDIA_TYPE_FIELD = "mediaType"; public static final String PUBLISHER_FIELD = "publisher"; @@ -28,18 +28,7 @@ public class AudioVisualPublication implements MusicPerformanceManifestation, Un @JsonProperty(TRACK_LIST_FIELD) private final List trackList; - @Deprecated @JsonCreator - public static AudioVisualPublication fromJson(@JsonProperty(MEDIA_TYPE_FIELD) MusicMediaType mediaType, - @JsonProperty(PUBLISHER_FIELD) Object publisher, - @JsonProperty(CATALOGUE_NUMBER_FIELD) String catalogueNumber, - @JsonProperty(TRACK_LIST_FIELD) List trackList) { - var publishingHouse = publisher instanceof String - ? new UnconfirmedPublisher((String) publisher) - : UnconfirmedPublisherMigrator.toPublisher(publisher); - return new AudioVisualPublication(mediaType, publishingHouse, catalogueNumber, trackList); - } - public AudioVisualPublication(@JsonProperty(MEDIA_TYPE_FIELD) MusicMediaType mediaType, @JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher, @JsonProperty(CATALOGUE_NUMBER_FIELD) String catalogueNumber, diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/MusicScore.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/MusicScore.java index 93ed722a3..2a6efb33b 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/MusicScore.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/artistic/music/MusicScore.java @@ -4,14 +4,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; -import java.util.Objects; import no.unit.nva.model.contexttypes.PublishingHouse; -import no.unit.nva.model.contexttypes.UnconfirmedPublisher; -import no.unit.nva.model.instancetypes.artistic.UnconfirmedPublisherMigrator; import nva.commons.core.JacocoGenerated; +import java.util.Objects; + @JsonTypeInfo(use = Id.NAME, property = "type") -public class MusicScore implements MusicPerformanceManifestation, UnconfirmedPublisherMigrator { +public class MusicScore implements MusicPerformanceManifestation { public static final String ENSEMBLE_FIELD = "ensemble"; public static final String MOVEMENTS_FIELD = "movements"; @@ -34,25 +33,12 @@ public class MusicScore implements MusicPerformanceManifestation, UnconfirmedPub private final Isrc isrc; @JsonCreator - public static MusicScore fromJson(@JsonProperty(ENSEMBLE_FIELD) String ensemble, - @JsonProperty(MOVEMENTS_FIELD) String movements, - @JsonProperty(EXTENT_FIELD) String extent, - @JsonProperty(PUBLISHER_FIELD) Object publisher, - @JsonProperty(ISMN_FIELD) Ismn ismn, - @JsonProperty(ISRC_FIELD) Isrc isrc) { - var publishingHouse = publisher instanceof String - ? new UnconfirmedPublisher((String) publisher) - : UnconfirmedPublisherMigrator.toPublisher(publisher); - return new MusicScore(ensemble, movements, extent, publishingHouse, ismn, isrc); - } - public MusicScore(@JsonProperty(ENSEMBLE_FIELD) String ensemble, @JsonProperty(MOVEMENTS_FIELD) String movements, @JsonProperty(EXTENT_FIELD) String extent, @JsonProperty(PUBLISHER_FIELD) PublishingHouse publisher, @JsonProperty(ISMN_FIELD) Ismn ismn, @JsonProperty(ISRC_FIELD) Isrc isrc) { - this.ensemble = ensemble; this.movements = movements; this.extent = extent; diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonograph.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonograph.java index 99cf10899..72ed84dad 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonograph.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonograph.java @@ -1,49 +1,20 @@ package no.unit.nva.model.instancetypes.book; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import no.unit.nva.model.instancetypes.PublicationInstance; import no.unit.nva.model.pages.MonographPages; +import no.unit.nva.model.instancetypes.PublicationInstance; import nva.commons.core.JacocoGenerated; import java.util.Objects; -import static java.util.Objects.isNull; - -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") public class BookMonograph implements PublicationInstance { public static final String PAGES_FIELD = "pages"; - private static final String CONTENT_TYPE_FIELD = "contentType"; private final MonographPages pages; - public BookMonograph(@JsonProperty(PAGES_FIELD) MonographPages pages) { + public BookMonograph(MonographPages pages) { this.pages = pages; } - @JsonCreator - public static BookMonograph fromJson(@JsonProperty(PAGES_FIELD) MonographPages pages, - @JsonProperty(CONTENT_TYPE_FIELD) BookMonographContentType contentType) { - if (BookMonographContentType.ACADEMIC_MONOGRAPH.equals(contentType)) { - return new AcademicMonograph(pages); - } else if (BookMonographContentType.ENCYCLOPEDIA.equals(contentType)) { - return new Encyclopedia(pages); - } else if (BookMonographContentType.EXHIBITION_CATALOG.equals(contentType)) { - return new ExhibitionCatalog(pages); - } else if (BookMonographContentType.NON_FICTION_MONOGRAPH.equals(contentType)) { - return new NonFictionMonograph(pages); - } else if (BookMonographContentType.POPULAR_SCIENCE_MONOGRAPH.equals(contentType)) { - return new PopularScienceMonograph(pages); - } else if (BookMonographContentType.TEXTBOOK.equals(contentType)) { - return new Textbook(pages); - } else if (isNull(contentType)) { - return new AcademicMonograph(pages); - } else { - throw new UnsupportedOperationException("The Book Monograph subtype is unknown"); - } - } - @Override public MonographPages getPages() { return pages; diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonographContentType.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonographContentType.java index 633bfd822..e69de29bb 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonographContentType.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/book/BookMonographContentType.java @@ -1,63 +0,0 @@ -package no.unit.nva.model.instancetypes.book; - -import static java.lang.String.format; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.joining; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Content Type options for "Monograph" subtype when the creator chooses the Resource type as "Book" while doing the - * registration. - */ -@Deprecated -public enum BookMonographContentType { - ACADEMIC_MONOGRAPH("AcademicMonograph", "Academic Monograph"), - NON_FICTION_MONOGRAPH("NonFictionMonograph", "Non-fiction Monograph"), - POPULAR_SCIENCE_MONOGRAPH("PopularScienceMonograph", "Popular Science Monograph"), - TEXTBOOK("Textbook", "Textbook"), - ENCYCLOPEDIA("Encyclopedia", "Encyclopedia"), - /** - * Enum Type Exhibition catalogue represents: A book published for a specific art or museum exhibition. Contains a - * list of exhibits at the exhibition. - */ - EXHIBITION_CATALOG("ExhibitionCatalog", "Exhibition catalog"); - - public static final String ERROR_MESSAGE_TEMPLATE = "%s not a valid BookMonographContentType, expected one of: %s"; - public static final String DELIMITER = ", "; - - private final String value; - private final String deprecatedValue; - - BookMonographContentType(String value, String deprecatedValue) { - this.value = value; - this.deprecatedValue = deprecatedValue; - } - - @JsonCreator - public static BookMonographContentType lookup(String value) { - return stream(values()) - .filter(nameType -> equalsCurrentOrDeprecatedValue(value, nameType)) - .findAny() - .orElseThrow(() -> new IllegalArgumentException(createErrorMessage(value))); - } - - @JsonValue - public String getValue() { - return value; - } - - private String getDeprecatedValue() { - return deprecatedValue; - } - - private static boolean equalsCurrentOrDeprecatedValue(String value, BookMonographContentType nameType) { - return nameType.getValue().equalsIgnoreCase(value) - || nameType.getDeprecatedValue().equalsIgnoreCase(value); - } - - private static String createErrorMessage(String value) { - return format(ERROR_MESSAGE_TEMPLATE, value, stream(BookMonographContentType.values()) - .map(BookMonographContentType::toString).collect(joining(DELIMITER))); - } -} diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticle.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticle.java index 69b6d5c3f..80e84ca38 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticle.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticle.java @@ -1,17 +1,11 @@ package no.unit.nva.model.instancetypes.chapter; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeInfo; import no.unit.nva.model.instancetypes.PublicationInstance; import no.unit.nva.model.pages.Range; import nva.commons.core.JacocoGenerated; import java.util.Objects; -import static java.util.Objects.isNull; - -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") public class ChapterArticle implements PublicationInstance { public static final String PAGES_FIELD = "pages"; @@ -21,30 +15,6 @@ public ChapterArticle(Range pages) { this.pages = pages; } - @JsonCreator - public static ChapterArticle fromJson(@JsonProperty(PAGES_FIELD) Range pages, - @JsonProperty("contentType") ChapterArticleContentType contentType) { - if (ChapterArticleContentType.ACADEMIC_CHAPTER.equals(contentType)) { - return new AcademicChapter(pages); - } else if (ChapterArticleContentType.ENCYCLOPEDIA_CHAPTER.equals(contentType)) { - return new EncyclopediaChapter(pages); - } else if (ChapterArticleContentType.EXHIBITION_CATALOG_CHAPTER.equals(contentType)) { - return new ExhibitionCatalogChapter(pages); - } else if (ChapterArticleContentType.INTRODUCTION.equals(contentType)) { - return new Introduction(pages); - } else if (ChapterArticleContentType.NON_FICTION_CHAPTER.equals(contentType)) { - return new NonFictionChapter(pages); - } else if (ChapterArticleContentType.POPULAR_SCIENCE_CHAPTER.equals(contentType)) { - return new PopularScienceChapter(pages); - } else if (ChapterArticleContentType.TEXTBOOK_CHAPTER.equals(contentType)) { - return new TextbookChapter(pages); - } else if (isNull(contentType)) { - return new AcademicChapter(pages); - } else { - throw new UnsupportedOperationException("The Chapter article subtype is unknown"); - } - } - @Override public Range getPages() { return pages; diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticleContentType.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticleContentType.java index 9c482164f..e69de29bb 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticleContentType.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/chapter/ChapterArticleContentType.java @@ -1,67 +0,0 @@ -package no.unit.nva.model.instancetypes.chapter; - -import static java.lang.String.format; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.joining; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Content type for 'Chapter in Anthology' resource subtype when the creator chooses, 'Chapter' Resource type while - * registering a publication. - */ -@Deprecated -public enum ChapterArticleContentType { - ACADEMIC_CHAPTER("AcademicChapter", "Academic Chapter"), - NON_FICTION_CHAPTER("NonFictionChapter", "Non-fiction Chapter"), - POPULAR_SCIENCE_CHAPTER("PopularScienceChapter", "Popular Science Chapter"), - TEXTBOOK_CHAPTER("TextbookChapter", "Textbook Chapter"), - ENCYCLOPEDIA_CHAPTER("EncyclopediaChapter", "Encyclopedia Chapter"), - /** - * Introduction in anthology: Introductory chapter in an anthology. - */ - INTRODUCTION("Introduction", "Introduction"), - /** - * Chapter in Exhibition catalogue: A chapter in an exhibition catalogue, if it is written as an anthology and not a - * monograph. - */ - EXHIBITION_CATALOG_CHAPTER("ExhibitionCatalogChapter", "Exhibition Catalog Chapter"); - - public static final String ERROR_MESSAGE_TEMPLATE = "%s not a valid ChapterContentType, expected one of: %s"; - public static final String DELIMITER = ", "; - - private final String value; - private final String deprecatedValue; - - ChapterArticleContentType(String value, String deprecatedValue) { - this.value = value; - this.deprecatedValue = deprecatedValue; - } - - @JsonCreator - public static ChapterArticleContentType lookup(String value) { - return stream(values()) - .filter(nameType -> equalsCurrentOrDeprecatedValue(value, nameType)) - .findAny() - .orElseThrow(() -> new IllegalArgumentException(createErrorMessage(value))); - } - - @JsonValue - public String getValue() { - return value; - } - - private String getDeprecatedValue() { - return deprecatedValue; - } - - private static boolean equalsCurrentOrDeprecatedValue(String value, ChapterArticleContentType nameType) { - return nameType.getValue().equalsIgnoreCase(value) - || nameType.getDeprecatedValue().equalsIgnoreCase(value); - } - - private static String createErrorMessage(String value) { - return format(ERROR_MESSAGE_TEMPLATE, value, stream(ChapterArticleContentType.values()) - .map(ChapterArticleContentType::toString).collect(joining(DELIMITER))); - } -} diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/journal/JournalArticle.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/journal/JournalArticle.java index 630d36f17..83c35a2e6 100644 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/journal/JournalArticle.java +++ b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/journal/JournalArticle.java @@ -1,7 +1,5 @@ package no.unit.nva.model.instancetypes.journal; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import no.unit.nva.model.instancetypes.PublicationInstance; import no.unit.nva.model.pages.Range; @@ -9,8 +7,6 @@ import java.util.Objects; -import static java.util.Objects.isNull; - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") public class JournalArticle implements PublicationInstance { public static final String PAGES_FIELD = "pages"; @@ -18,7 +14,6 @@ public class JournalArticle implements PublicationInstance { public static final String VOLUME_FIELD = "volume"; public static final String ISSUE_FIELD = "issue"; public static final String ARTICLE_NUMBER_FIELD = "articleNumber"; - public static final String CONTENT_TYPE_FIELD = "contentType"; private final Range pages; private final String volume; private final String issue; @@ -34,31 +29,6 @@ protected JournalArticle(Range pages, this.articleNumber = articleNumber; } - @JsonCreator - public static JournalArticle fromJson(@JsonProperty(PAGES_FIELD) Range pages, - @JsonProperty(VOLUME_FIELD) String volume, - @JsonProperty(ISSUE_FIELD) String issue, - @JsonProperty(ARTICLE_NUMBER_FIELD) String articleNumber, - @JsonProperty(CONTENT_TYPE_FIELD) JournalArticleContentType contentType) { - if (JournalArticleContentType.ACADEMIC_ARTICLE.equals(contentType)) { - return new AcademicArticle(pages, volume, issue, articleNumber); - } else if (JournalArticleContentType.ACADEMIC_LITERATURE_REVIEW.equals(contentType)) { - return new AcademicLiteratureReview(pages, volume, issue, articleNumber); - } else if (JournalArticleContentType.CASE_REPORT.equals(contentType)) { - return new CaseReport(pages, volume, issue, articleNumber); - } else if (JournalArticleContentType.POPULAR_SCIENCE_ARTICLE.equals(contentType)) { - return new PopularScienceArticle(pages, volume, issue, articleNumber); - } else if (JournalArticleContentType.PROFESSIONAL_ARTICLE.equals(contentType)) { - return new ProfessionalArticle(pages, volume, issue, articleNumber); - } else if (JournalArticleContentType.STUDY_PROTOCOL.equals(contentType)) { - return new StudyProtocol(pages, volume, issue, articleNumber); - } else if (isNull(contentType)) { - return new AcademicArticle(pages, volume, issue, articleNumber); - } else { - throw new UnsupportedOperationException("The Journal article subtype is unknown"); - } - } - public String getVolume() { return volume; } diff --git a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/journal/JournalArticleContentType.java b/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/journal/JournalArticleContentType.java deleted file mode 100644 index 62bbee54c..000000000 --- a/nva-datamodel-java/src/main/java/no/unit/nva/model/instancetypes/journal/JournalArticleContentType.java +++ /dev/null @@ -1,56 +0,0 @@ -package no.unit.nva.model.instancetypes.journal; - -import static java.lang.String.format; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.joining; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -@Deprecated -public enum JournalArticleContentType { - ACADEMIC_ARTICLE("AcademicArticle", "Research article"), - ACADEMIC_LITERATURE_REVIEW("AcademicLiteratureReview", "Review article"), - CASE_REPORT("CaseReport", "Case report"), - STUDY_PROTOCOL("StudyProtocol", "Study protocol"), - PROFESSIONAL_ARTICLE("ProfessionalArticle", "Professional article"), - POPULAR_SCIENCE_ARTICLE("PopularScienceArticle", "Popular science article"); - - public static final String ERROR_MESSAGE_TEMPLATE = "%s not a valid JournalArticleContentType, expected one of: %s"; - public static final String DELIMITER = ", "; - - private final String value; - private final String deprecatedValue; - - JournalArticleContentType(String value, String deprecatedValue) { - this.deprecatedValue = deprecatedValue; - this.value = value; - } - - @JsonCreator - public static JournalArticleContentType lookup(String value) { - return stream(values()) - .filter(nameType -> equalsCurrentOrDeprecatedValue(value, nameType)) - .findAny() - .orElseThrow(() -> new IllegalArgumentException(createErrorMessage(value))); - } - - @JsonValue - public String getValue() { - return value; - } - - @Deprecated - private String getDeprecatedValue() { - return deprecatedValue; - } - - private static boolean equalsCurrentOrDeprecatedValue(String value, JournalArticleContentType nameType) { - return nameType.getValue().equalsIgnoreCase(value) - || nameType.getDeprecatedValue().equalsIgnoreCase(value); - } - - private static String createErrorMessage(String value) { - return format(ERROR_MESSAGE_TEMPLATE, value, stream(JournalArticleContentType.values()) - .map(JournalArticleContentType::toString).collect(joining(DELIMITER))); - } -} diff --git a/nva-datamodel-java/src/test/java/no/unit/nva/MigrateChapterArticleSubtypesTest.java b/nva-datamodel-java/src/test/java/no/unit/nva/MigrateChapterArticleSubtypesTest.java deleted file mode 100644 index 35bb98275..000000000 --- a/nva-datamodel-java/src/test/java/no/unit/nva/MigrateChapterArticleSubtypesTest.java +++ /dev/null @@ -1,199 +0,0 @@ -package no.unit.nva; - -import no.unit.nva.commons.json.JsonUtils; -import no.unit.nva.model.Publication; -import no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; - -import static nva.commons.core.attempt.Try.attempt; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; - -class MigrateChapterArticleSubtypesTest { - @ParameterizedTest - @EnumSource(ChapterArticleContentType.class) - void shouldDeserializeOldSubtypeBookMonographContentTypeAsType(ChapterArticleContentType content) { - var type = content.getValue(); - var json = generateFullChapterArticleWithContentType(type); - var chapterArticle = attempt(() -> JsonUtils.dtoObjectMapper.readValue(json, Publication.class)) - .orElseThrow(); - var actual = chapterArticle.getEntityDescription() - .getReference().getPublicationInstance().getClass().getSimpleName(); - assertThat(actual, is(equalTo(type))); - } - - private String generateFullChapterArticleWithContentType(String type) { - return "{\n" - + " \"type\" : \"Publication\",\n" - + " \"identifier\" : \"c443030e-9d56-43d8-afd1-8c89105af555\",\n" - + " \"status\" : \"NEW\",\n" - + " \"resourceOwner\" : {\n" - + " \"owner\" : \"RuYrbdooUL32\",\n" - + " \"ownerAffiliation\" : \"https://www.example.org/repellateum\"\n" - + " },\n" - + " \"publisher\" : {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.org/errorrem\",\n" - + " \"labels\" : {\n" - + " \"bg\" : \"ttgW11eA97cznnf4GC4\"\n" - + " }\n" - + " },\n" - + " \"createdDate\" : \"2020-07-28T09:09:48.320Z\",\n" - + " \"modifiedDate\" : \"2002-08-03T23:05:35.416Z\",\n" - + " \"publishedDate\" : \"1991-09-28T07:19:46.957Z\",\n" - + " \"indexedDate\" : \"1983-09-18T05:29:53.500Z\",\n" - + " \"handle\" : \"https://www.example.org/repudiandaeullam\",\n" - + " \"doi\" : \"https://doi.org/10.1234/dolore\",\n" - + " \"link\" : \"https://www.example.org/reprehenderitsaepe\",\n" - + " \"entityDescription\" : {\n" - + " \"type\" : \"EntityDescription\",\n" - + " \"mainTitle\" : \"BLYSKI1nfdbkv\",\n" - + " \"alternativeTitles\" : {\n" - + " \"el\" : \"zm6679gekbLZW\"\n" - + " },\n" - + " \"language\" : \"http://lexvo.org/id/iso639-3/und\",\n" - + " \"date\" : {\n" - + " \"type\" : \"PublicationDate\",\n" - + " \"year\" : \"XXAhi6akNONu\",\n" - + " \"month\" : \"HEQzNoatbd6NSMKHRg0\",\n" - + " \"day\" : \"2ESjpduz4r7bS\"\n" - + " },\n" - + " \"contributors\" : [ {\n" - + " \"type\" : \"Contributor\",\n" - + " \"identity\" : {\n" - + " \"type\" : \"Identity\",\n" - + " \"id\" : \"https://www.example.com/XhSa9gtoce12\",\n" - + " \"name\" : \"75efqCBNvlir7c\",\n" - + " \"nameType\" : \"Organizational\",\n" - + " \"orcId\" : \"t5ZYTi4TYLff\"\n" - + " },\n" - + " \"affiliations\" : [ {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.com/6HhoBSEkueTu2Z\",\n" - + " \"labels\" : {\n" - + " \"cs\" : \"x4Pn570F0gnE\"\n" - + " }\n" - + " } ],\n" - + " \"role\" : \"Curator\",\n" - + " \"sequence\" : 0,\n" - + " \"correspondingAuthor\" : false\n" - + " }, {\n" - + " \"type\" : \"Contributor\",\n" - + " \"identity\" : {\n" - + " \"type\" : \"Identity\",\n" - + " \"id\" : \"https://www.example.com/XzqAR37csm9zWJ\",\n" - + " \"name\" : \"4R2jeB61pvak8IWqj8H\",\n" - + " \"nameType\" : \"Organizational\",\n" - + " \"orcId\" : \"Aog7SFb5e54M\"\n" - + " },\n" - + " \"affiliations\" : [ {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.com/N6MywIzDqqmSv4k4\",\n" - + " \"labels\" : {\n" - + " \"en\" : \"OL3z1bGqeL0LzNza\"\n" - + " }\n" - + " } ],\n" - + " \"role\" : \"Artist\",\n" - + " \"sequence\" : 5,\n" - + " \"correspondingAuthor\" : false\n" - + " } ],\n" - + " \"npiSubjectHeading\" : \"Rk8MXIukbIzwqLP6\",\n" - + " \"tags\" : [ \"S4dKS7Cn5r6\" ],\n" - + " \"description\" : \"w2BzLiBJVxLFuROrnY\",\n" - + " \"reference\" : {\n" - + " \"type\" : \"Reference\",\n" - + " \"publicationContext\" : {\n" - + " \"type\" : \"Chapter\",\n" - + " \"partOf\" : \"https://www.example.com/8Fj6K3c2Eyx\"\n" - + " },\n" - + " \"doi\" : \"https://www.example.com/TVeL0ieitk1mLBbMH\",\n" - + " \"publicationInstance\" : {\n" - + " \"type\" : \"ChapterArticle\",\n" - + " \"contentType\" : \"" + type + "\",\n" - + " \"peerReviewed\" : true,\n" - + " \"originalResearch\" : true,\n" - + " \"pages\" : {\n" - + " \"type\" : \"Range\",\n" - + " \"begin\" : \"qDEY1GhYXtxTVxAdE\",\n" - + " \"end\" : \"r3L4UKe6bg10Sqoj\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"metadataSource\" : \"https://www.example.com/Ag6Qro62b8DvL9p4\",\n" - + " \"abstract\" : \"CBLk1w1sHe\"\n" - + " },\n" - + " \"projects\" : [ {\n" - + " \"type\" : \"ResearchProject\",\n" - + " \"id\" : \"https://www.example.org/aliassaepe\",\n" - + " \"name\" : \"LOumMwmN3JQmFxCY8Ha\",\n" - + " \"approvals\" : [ {\n" - + " \"type\" : \"Approval\",\n" - + " \"date\" : \"2023-01-08T09:20:28.086Z\",\n" - + " \"approvedBy\" : \"REK\",\n" - + " \"approvalStatus\" : \"DECLINED\",\n" - + " \"applicationCode\" : \"xwWwEn0awmly\"\n" - + " } ]\n" - + " } ],\n" - + " \"fundings\" : [ {\n" - + " \"type\" : \"UnconfirmedFunding\",\n" - + " \"source\" : \"https://www.example.org/voluptatemsed\",\n" - + " \"identifier\" : \"Ue3A2hsgEG\",\n" - + " \"labels\" : {\n" - + " \"fr\" : \"gUeWn5rgnIaZ902P0Gm\"\n" - + " },\n" - + " \"fundingAmount\" : {\n" - + " \"currency\" : \"USD\",\n" - + " \"amount\" : 161825051\n" - + " },\n" - + " \"activeFrom\" : \"2011-05-05T00:03:24.088Z\",\n" - + " \"activeTo\" : \"2019-03-27T14:38:32.956Z\"\n" - + " }, {\n" - + " \"type\" : \"ConfirmedFunding\",\n" - + " \"source\" : \"https://www.example.org/laboriosamneque\",\n" - + " \"id\" : \"https://www.example.org/nullaquia\",\n" - + " \"identifier\" : \"Dl1wT7xbmq4C2I4sQKx\",\n" - + " \"labels\" : {\n" - + " \"da\" : \"H1ERfelmzeBQxdSs\"\n" - + " },\n" - + " \"fundingAmount\" : {\n" - + " \"currency\" : \"GBP\",\n" - + " \"amount\" : 981864134\n" - + " },\n" - + " \"activeFrom\" : \"1973-04-26T21:20:47.124Z\",\n" - + " \"activeTo\" : \"2018-03-07T11:19:24.360Z\"\n" - + " } ],\n" - + " \"additionalIdentifiers\" : [ {\n" - + " \"type\" : \"AdditionalIdentifier\",\n" - + " \"source\" : \"fakesource\",\n" - + " \"value\" : \"1234\"\n" - + " } ],\n" - + " \"subjects\" : [ \"https://www.example.org/maximevel\" ],\n" - + " \"associatedArtifacts\" : [ {\n" - + " \"type\" : \"PublishedFile\",\n" - + " \"identifier\" : \"46725458-c60c-44a6-a952-41d25c9e5de3\",\n" - + " \"name\" : \"gEUP4JgMXh1Q\",\n" - + " \"mimeType\" : \"orcFMiw4ZnM\",\n" - + " \"size\" : 1581080284,\n" - + " \"license\" : {\n" - + " \"type\" : \"License\",\n" - + " \"identifier\" : \"7PYHmgVdvENJTYWcm\",\n" - + " \"labels\" : {\n" - + " \"fi\" : \"0SwxwFiSVRwQvz5ijCd\"\n" - + " },\n" - + " \"link\" : \"https://www.example.com/PSyujG3bq4ccWVvdhL\"\n" - + " },\n" - + " \"administrativeAgreement\" : false,\n" - + " \"publisherAuthority\" : true,\n" - + " \"visibleForNonOwner\" : true\n" - + " }, {\n" - + " \"type\" : \"AssociatedLink\",\n" - + " \"id\" : \"https://www.example.com/GclXAVyGmqRrJ\",\n" - + " \"name\" : \"XS2oxVRgVr\",\n" - + " \"description\" : \"xRPrvEVJRdwxZ\"\n" - + " } ],\n" - + " \"modelVersion\" : \"0.19.29\"\n" - + "}"; - } -} diff --git a/nva-datamodel-java/src/test/java/no/unit/nva/MigrationBookMonographSubtypesTest.java b/nva-datamodel-java/src/test/java/no/unit/nva/MigrationBookMonographSubtypesTest.java deleted file mode 100644 index 6c287c818..000000000 --- a/nva-datamodel-java/src/test/java/no/unit/nva/MigrationBookMonographSubtypesTest.java +++ /dev/null @@ -1,214 +0,0 @@ -package no.unit.nva; - -import no.unit.nva.commons.json.JsonUtils; -import no.unit.nva.model.Publication; -import no.unit.nva.model.instancetypes.book.BookMonographContentType; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; - -import static nva.commons.core.attempt.Try.attempt; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; - -@Deprecated -class MigrationBookMonographSubtypesTest { - @ParameterizedTest - @EnumSource(BookMonographContentType.class) - void shouldDeserializeOldSubtypeBookMonographContentTypeAsType(BookMonographContentType content) { - var type = content.getValue(); - var json = generateFullBookMonographWithContentType(type); - var bookMonograph = attempt(() -> JsonUtils.dtoObjectMapper.readValue(json, Publication.class)) - .orElseThrow(); - var actual = bookMonograph.getEntityDescription() - .getReference().getPublicationInstance().getClass().getSimpleName(); - assertThat(actual, is(equalTo(type))); - } - - private String generateFullBookMonographWithContentType(String type) { - return "{\n" - + " \"type\" : \"Publication\",\n" - + " \"identifier\" : \"c443030e-9d56-43d8-afd1-8c89105af555\",\n" - + " \"status\" : \"NEW\",\n" - + " \"resourceOwner\" : {\n" - + " \"owner\" : \"tB62sIFYKg\",\n" - + " \"ownerAffiliation\" : \"https://www.example.org/commodiut\"\n" - + " },\n" - + " \"publisher\" : {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.org/suscipitat\",\n" - + " \"labels\" : {\n" - + " \"ru\" : \"mrH4HAV6aEDjGNRJ2\"\n" - + " }\n" - + " },\n" - + " \"createdDate\" : \"1972-05-08T00:12:05.315Z\",\n" - + " \"modifiedDate\" : \"2019-09-28T13:25:15.960Z\",\n" - + " \"publishedDate\" : \"1975-01-08T02:19:20.777Z\",\n" - + " \"indexedDate\" : \"2007-03-21T06:29:45.706Z\",\n" - + " \"handle\" : \"https://www.example.org/expeditaaliquam\",\n" - + " \"doi\" : \"https://doi.org/10.1234/voluptas\",\n" - + " \"link\" : \"https://www.example.org/hicsoluta\",\n" - + " \"entityDescription\" : {\n" - + " \"type\" : \"EntityDescription\",\n" - + " \"mainTitle\" : \"TJiBWzUbcYOsg1Bh6ar\",\n" - + " \"alternativeTitles\" : {\n" - + " \"pl\" : \"u6W8XtFlErl7CT20H\"\n" - + " },\n" - + " \"language\" : \"http://lexvo.org/id/iso639-3/und\",\n" - + " \"date\" : {\n" - + " \"type\" : \"PublicationDate\",\n" - + " \"year\" : \"tYcREtuLoDw5l9YZV\",\n" - + " \"month\" : \"gMzfA9CfARP0qdRT\",\n" - + " \"day\" : \"EiJQbxbLQZj\"\n" - + " },\n" - + " \"contributors\" : [ {\n" - + " \"type\" : \"Contributor\",\n" - + " \"identity\" : {\n" - + " \"type\" : \"Identity\",\n" - + " \"id\" : \"https://www.example.com/GqttyV980NRYL8Pfp\",\n" - + " \"name\" : \"rA6GkyIRJGv2di\",\n" - + " \"nameType\" : \"Personal\",\n" - + " \"orcId\" : \"9DtRI5qSVrxx\"\n" - + " },\n" - + " \"affiliations\" : [ {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.com/O9IL4Q16jMMTmyFa\",\n" - + " \"labels\" : {\n" - + " \"af\" : \"A3H5OIKOwrqriOct\"\n" - + " }\n" - + " } ],\n" - + " \"role\" : \"ContactPerson\",\n" - + " \"sequence\" : 7,\n" - + " \"correspondingAuthor\" : false\n" - + " }, {\n" - + " \"type\" : \"Contributor\",\n" - + " \"identity\" : {\n" - + " \"type\" : \"Identity\",\n" - + " \"id\" : \"https://www.example.com/Ele611kKvbKnqeL\",\n" - + " \"name\" : \"TIE6zIiWCWLpfvK\",\n" - + " \"nameType\" : \"Organizational\",\n" - + " \"orcId\" : \"aJ1pvnZ8FVOh5\"\n" - + " },\n" - + " \"affiliations\" : [ {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.com/CszMv40Wx2OX\",\n" - + " \"labels\" : {\n" - + " \"af\" : \"CCP5RUwJlFTQTzL\"\n" - + " }\n" - + " } ],\n" - + " \"role\" : \"Dramatist\",\n" - + " \"sequence\" : 0,\n" - + " \"correspondingAuthor\" : false\n" - + " } ],\n" - + " \"npiSubjectHeading\" : \"RCjSANi9tVDH0X1lEN\",\n" - + " \"tags\" : [ \"gyNAMEiHlZuJT\" ],\n" - + " \"description\" : \"TBlPsIoaVroQdh\",\n" - + " \"reference\" : {\n" - + " \"type\" : \"Reference\",\n" - + " \"publicationContext\" : {\n" - + " \"type\" : \"Book\",\n" - + " \"series\" : {\n" - + " \"type\" : \"Series\",\n" - + " \"id\" : \"https://api.dev.nva.aws.unit.no/publication-channels/gTApbmIXv6\"\n" - + " },\n" - + " \"seriesNumber\" : \"wmHi1PgzWPm86KCe6\",\n" - + " \"publisher\" : {\n" - + " \"type\" : \"Publisher\",\n" - + " \"id\" : \"https://api.dev.nva.aws.unit.no/publication-channels/rLViYfagIJ\"\n" - + " },\n" - + " \"isbnList\" : [ \"9790094516099\" ]\n" - + " },\n" - + " \"doi\" : \"https://www.example.com/FbubVFoXuT\",\n" - + " \"publicationInstance\" : {\n" - + " \"type\" : \"BookMonograph\",\n" - + " \"contentType\" : \"" + type + "\",\n" - + " \"originalResearch\" : false,\n" - + " \"peerReviewed\" : false,\n" - + " \"pages\" : {\n" - + " \"type\" : \"MonographPages\",\n" - + " \"introduction\" : {\n" - + " \"type\" : \"Range\",\n" - + " \"begin\" : \"9n2jMU0p6vPI9pcqQyi\",\n" - + " \"end\" : \"QAYvjiCUvm\"\n" - + " },\n" - + " \"pages\" : \"rXSsjeWG62j\",\n" - + " \"illustrated\" : false\n" - + " }\n" - + " }\n" - + " },\n" - + " \"metadataSource\" : \"https://www.example.com/TJrqCkHQVrIt0j\",\n" - + " \"abstract\" : \"TRcbF8cf89PgTuBk\"\n" - + " },\n" - + " \"projects\" : [ {\n" - + " \"type\" : \"ResearchProject\",\n" - + " \"id\" : \"https://www.example.org/perferendisharum\",\n" - + " \"name\" : \"ESFpOgIIS4q9dW6\",\n" - + " \"approvals\" : [ {\n" - + " \"type\" : \"Approval\",\n" - + " \"date\" : \"1993-11-28T10:21:43.195Z\",\n" - + " \"approvedBy\" : \"NARA\",\n" - + " \"approvalStatus\" : \"APPLIED\",\n" - + " \"applicationCode\" : \"UZlpisZwYl0NJVz6lLy\"\n" - + " } ]\n" - + " } ],\n" - + " \"fundings\" : [ {\n" - + " \"type\" : \"UnconfirmedFunding\",\n" - + " \"source\" : \"https://www.example.org/eamagnam\",\n" - + " \"identifier\" : \"0kIBfGDot4QwO2kb\",\n" - + " \"labels\" : {\n" - + " \"it\" : \"JF3ZSl24zL\"\n" - + " },\n" - + " \"fundingAmount\" : {\n" - + " \"currency\" : \"USD\",\n" - + " \"amount\" : 1138272242\n" - + " },\n" - + " \"activeFrom\" : \"2003-11-07T09:15:50.695Z\",\n" - + " \"activeTo\" : \"2015-08-01T19:20:16.941Z\"\n" - + " }, {\n" - + " \"type\" : \"ConfirmedFunding\",\n" - + " \"source\" : \"https://www.example.org/fugiatsapiente\",\n" - + " \"id\" : \"https://www.example.org/suntmagni\",\n" - + " \"identifier\" : \"BNo5moC50NfbNBo\",\n" - + " \"labels\" : {\n" - + " \"sv\" : \"q7am4xSOFZpHduBza\"\n" - + " },\n" - + " \"fundingAmount\" : {\n" - + " \"currency\" : \"EUR\",\n" - + " \"amount\" : 873582428\n" - + " },\n" - + " \"activeFrom\" : \"1974-04-25T00:39:51.618Z\",\n" - + " \"activeTo\" : \"2018-06-05T01:03:44.768Z\"\n" - + " } ],\n" - + " \"additionalIdentifiers\" : [ {\n" - + " \"type\" : \"AdditionalIdentifier\",\n" - + " \"source\" : \"fakesource\",\n" - + " \"value\" : \"1234\"\n" - + " } ],\n" - + " \"subjects\" : [ \"https://www.example.org/quaeratdolorem\" ],\n" - + " \"associatedArtifacts\" : [ {\n" - + " \"type\" : \"PublishedFile\",\n" - + " \"identifier\" : \"86406e82-636e-4ddb-8e07-fd6619ec3aa0\",\n" - + " \"name\" : \"bNvv7O5PyKT\",\n" - + " \"mimeType\" : \"gVDXmTw9H2gqBRm\",\n" - + " \"size\" : 838225864,\n" - + " \"license\" : {\n" - + " \"type\" : \"License\",\n" - + " \"identifier\" : \"Y1VBFAUQrmps39Lg\",\n" - + " \"labels\" : {\n" - + " \"bg\" : \"uhHKMW0QVPFmPcluDo\"\n" - + " },\n" - + " \"link\" : \"https://www.example.com/LwqTEw9Ulq\"\n" - + " },\n" - + " \"administrativeAgreement\" : false,\n" - + " \"publisherAuthority\" : true,\n" - + " \"visibleForNonOwner\" : true\n" - + " }, {\n" - + " \"type\" : \"AssociatedLink\",\n" - + " \"id\" : \"https://www.example.com/qlvWdNWNyFWfvk5qg6X\",\n" - + " \"name\" : \"Otvp1638EBdF0mJ\",\n" - + " \"description\" : \"ewjrLNbRKEdzqKM\"\n" - + " } ],\n" - + " \"modelVersion\" : \"0.19.29\"\n" - + "}"; - } -} diff --git a/nva-datamodel-java/src/test/java/no/unit/nva/MigrationJournalArticleSubtypes.java b/nva-datamodel-java/src/test/java/no/unit/nva/MigrationJournalArticleSubtypes.java deleted file mode 100644 index 29ca2c15c..000000000 --- a/nva-datamodel-java/src/test/java/no/unit/nva/MigrationJournalArticleSubtypes.java +++ /dev/null @@ -1,192 +0,0 @@ -package no.unit.nva; - -import no.unit.nva.commons.json.JsonUtils; -import no.unit.nva.model.Publication; -import no.unit.nva.model.instancetypes.journal.JournalArticleContentType; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; - -import static nva.commons.core.attempt.Try.attempt; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; - -@Deprecated -class MigrationJournalArticleSubtypes { - - @ParameterizedTest - @EnumSource(JournalArticleContentType.class) - void shouldDeserializeOldSubtypeJournalArticleContentTypeAsType(JournalArticleContentType content) { - var type = content.getValue(); - var json = generateFullJournalArticleWithContentType(type); - var journalArticle = attempt(() -> JsonUtils.dtoObjectMapper.readValue(json, Publication.class)) - .orElseThrow(); - var actual = journalArticle.getEntityDescription() - .getReference().getPublicationInstance().getClass().getSimpleName(); - assertThat(actual, is(equalTo(type))); - } - - private static String generateFullJournalArticleWithContentType(String contentType) { - return "{\n" - + " \"type\" : \"Publication\",\n" - + " \"identifier\" : \"c443030e-9d56-43d8-afd1-8c89105af555\",\n" - + " \"status\" : \"PUBLISHED_METADATA\",\n" - + " \"resourceOwner\" : {\n" - + " \"owner\" : \"4TmBjGCN1AmmBB4I3j\",\n" - + " \"ownerAffiliation\" : \"https://www.example.org/nobisqui\"\n" - + " },\n" - + " \"publisher\" : {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.org/amolestiae\",\n" - + " \"labels\" : {\n" - + " \"it\" : \"M2qeYhojtzlFhOf\"\n" - + " }\n" - + " },\n" - + " \"createdDate\" : \"1972-09-01T04:35:34.770Z\",\n" - + " \"modifiedDate\" : \"2001-08-13T14:29:04.580Z\",\n" - + " \"publishedDate\" : \"2020-12-23T06:01:38.371Z\",\n" - + " \"indexedDate\" : \"1980-08-06T18:33:15.367Z\",\n" - + " \"handle\" : \"https://www.example.org/ipsaea\",\n" - + " \"doi\" : \"https://doi.org/10.1234/eaque\",\n" - + " \"link\" : \"https://www.example.org/utvoluptatem\",\n" - + " \"entityDescription\" : {\n" - + " \"type\" : \"EntityDescription\",\n" - + " \"mainTitle\" : \"qIZNaXDKymx\",\n" - + " \"alternativeTitles\" : {\n" - + " \"is\" : \"Z9zlbat2Klf\"\n" - + " },\n" - + " \"language\" : \"http://lexvo.org/id/iso639-3/und\",\n" - + " \"date\" : {\n" - + " \"type\" : \"PublicationDate\",\n" - + " \"year\" : \"WhMPvnAqZD8c\",\n" - + " \"month\" : \"XkeaMca9UppPjCVvRK4\",\n" - + " \"day\" : \"wkAWmWCQ3M1brzNZiI\"\n" - + " },\n" - + " \"contributors\" : [ {\n" - + " \"type\" : \"Contributor\",\n" - + " \"identity\" : {\n" - + " \"type\" : \"Identity\",\n" - + " \"id\" : \"https://www.example.com/X4wvTuNwAc8QqQeB\",\n" - + " \"name\" : \"cpH3rsLYy2O9qzfP\",\n" - + " \"nameType\" : \"Organizational\",\n" - + " \"orcId\" : \"jhOSXlkR3PpeG4N\"\n" - + " },\n" - + " \"affiliations\" : [ {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.com/SHf08a2UT8yiL4\",\n" - + " \"labels\" : {\n" - + " \"hu\" : \"hzppegUya2siCVvvVJ\"\n" - + " }\n" - + " } ],\n" - + " \"role\" : \"Writer\",\n" - + " \"sequence\" : 4,\n" - + " \"correspondingAuthor\" : false\n" - + " }, {\n" - + " \"type\" : \"Contributor\",\n" - + " \"identity\" : {\n" - + " \"type\" : \"Identity\",\n" - + " \"id\" : \"https://www.example.com/7oS1BcncWcDwx2JP\",\n" - + " \"name\" : \"oVR3pdbUvaepV\",\n" - + " \"nameType\" : \"Organizational\",\n" - + " \"orcId\" : \"SKr9XyTuIi\"\n" - + " },\n" - + " \"affiliations\" : [ {\n" - + " \"type\" : \"Organization\",\n" - + " \"id\" : \"https://www.example.com/MeBieb0Tyihiy\",\n" - + " \"labels\" : {\n" - + " \"ca\" : \"Sto0PAY8C0\"\n" - + " }\n" - + " } ],\n" - + " \"role\" : \"Soloist\",\n" - + " \"sequence\" : 5,\n" - + " \"correspondingAuthor\" : false\n" - + " } ],\n" - + " \"npiSubjectHeading\" : \"GuBHWYxnyMn2gU\",\n" - + " \"tags\" : [ \"xpdNqJyRETrdW\" ],\n" - + " \"description\" : \"WIQwOUiT9Qu8HNQA\",\n" - + " \"reference\" : {\n" - + " \"type\" : \"Reference\",\n" - + " \"publicationContext\" : {\n" - + " \"type\" : \"Journal\",\n" - + " \"id\" : \"https://api.dev.nva.aws.unit.no/publication-channels/eujd55boZtis7Ql0\"\n" - + " },\n" - + " \"doi\" : \"https://www.example.com/aFCyqrhxxyTnOW\",\n" - + " \"publicationInstance\" : {\n" - + " \"type\" : \"JournalArticle\",\n" - + " \"volume\" : \"d8lgJKdVnFH51\",\n" - + " \"issue\" : \"1SOozXNuiS8uojXSO\",\n" - + " \"articleNumber\" : \"BtGFNkZzVs1CKwjJLz\",\n" - + " \"contentType\" : \"" + contentType + "\",\n" - + " \"peerReviewed\" : true,\n" - + " \"originalResearch\" : false,\n" - + " \"pages\" : {\n" - + " \"type\" : \"Range\",\n" - + " \"begin\" : \"OiCuLxrY5vHYhtB0\",\n" - + " \"end\" : \"cs3eFzfcJ9lzs\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"metadataSource\" : \"https://www.example.com/Q86zpd2W9M\",\n" - + " \"abstract\" : \"SzqBaTsSA44k\"\n" - + " },\n" - + " \"projects\" : [ {\n" - + " \"type\" : \"ResearchProject\",\n" - + " \"id\" : \"https://www.example.org/assumendaeum\",\n" - + " \"name\" : \"qr9KS9w6G67SrtUzGmv\",\n" - + " \"approvals\" : [ {\n" - + " \"type\" : \"Approval\",\n" - + " \"date\" : \"2020-08-30T12:38:40.124Z\",\n" - + " \"approvedBy\" : \"DIRHEALTH\",\n" - + " \"approvalStatus\" : \"NOTAPPLIED\",\n" - + " \"applicationCode\" : \"bK0XmCJlYNwE0oUNb\"\n" - + " } ]\n" - + " } ],\n" - + " \"fundings\" : [ {\n" - + " \"type\" : \"ConfirmedFunding\",\n" - + " \"source\" : \"https://www.example.org/atvoluptatibus\",\n" - + " \"id\" : \"https://www.example.org/cupiditatevoluptas\",\n" - + " \"identifier\" : \"5INZCCOTpFiP8YNFmCJ\",\n" - + " \"name\" : \"7kTCaw7kUQIgeI0SXDG\",\n" - + " \"alternativeName\" : {\n" - + " \"en\" : \"QNy99yR6zoqCFq\"\n" - + " },\n" - + " \"fundingAmount\" : {\n" - + " \"currency\" : \"EUR\",\n" - + " \"amount\" : 973238067\n" - + " },\n" - + " \"activeFrom\" : \"2011-06-06T01:00:52.156Z\",\n" - + " \"activeTo\" : \"2019-05-04T03:50:10.791Z\"\n" - + " } ],\n" - + " \"additionalIdentifiers\" : [ {\n" - + " \"type\" : \"AdditionalIdentifier\",\n" - + " \"source\" : \"fakesource\",\n" - + " \"value\" : \"1234\"\n" - + " } ],\n" - + " \"subjects\" : [ \"https://www.example.org/harumquasi\" ],\n" - + " \"associatedArtifacts\" : [ {\n" - + " \"type\" : \"PublishedFile\",\n" - + " \"identifier\" : \"d8c5785c-2100-4097-b461-a7269d78bf03\",\n" - + " \"name\" : \"63IPVTamuKud3NP\",\n" - + " \"mimeType\" : \"QBk86jTCqlPBH\",\n" - + " \"size\" : 463477975,\n" - + " \"license\" : {\n" - + " \"type\" : \"License\",\n" - + " \"identifier\" : \"nmTcPkIZJPrTYF7iGE\",\n" - + " \"labels\" : {\n" - + " \"pt\" : \"XrgMENjWTy\"\n" - + " },\n" - + " \"link\" : \"https://www.example.com/w8VjoRRwdEYOUK0\"\n" - + " },\n" - + " \"administrativeAgreement\" : false,\n" - + " \"publisherAuthority\" : true,\n" - + " \"visibleForNonOwner\" : true\n" - + " }, {\n" - + " \"type\" : \"AssociatedLink\",\n" - + " \"id\" : \"https://www.example.com/Y9CEp5BhRSsNG57Ve1G\",\n" - + " \"name\" : \"sz5x297ukf2\",\n" - + " \"description\" : \"mVzLj4RXFc5Zd6DBZ7o\"\n" - + " } ],\n" - + " \"modelVersion\" : \"0.19.28\"\n" - + "}"; - } -} diff --git a/nva-datamodel-java/src/test/java/no/unit/nva/MigrationTestingUnconfirmedPublisher.java b/nva-datamodel-java/src/test/java/no/unit/nva/MigrationTestingUnconfirmedPublisher.java deleted file mode 100644 index 527b68d08..000000000 --- a/nva-datamodel-java/src/test/java/no/unit/nva/MigrationTestingUnconfirmedPublisher.java +++ /dev/null @@ -1,152 +0,0 @@ -package no.unit.nva; - -import com.fasterxml.jackson.core.JsonProcessingException; -import no.unit.nva.commons.json.JsonUtils; -import no.unit.nva.model.instancetypes.artistic.film.realization.Broadcast; -import no.unit.nva.model.instancetypes.artistic.film.realization.OtherRelease; -import no.unit.nva.model.instancetypes.artistic.music.AudioVisualPublication; -import no.unit.nva.model.instancetypes.artistic.music.MusicScore; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -@Deprecated -public class MigrationTestingUnconfirmedPublisher { - - @ParameterizedTest - @ValueSource(strings = {"{\n" - + " \"type\": \"Broadcast\",\n" - + " \"publisher\": \"My publisher\",\n" - + " \"date\": {\n" - + " \"type\": \"Instant\",\n" - + " \"value\": \"2022-03-23T00:00:00.000000Z\"\n" - + " },\n" - + " \"sequence\": \"1\"\n" - + "}", - "{\n" - + " \"type\": \"Broadcast\",\n" - + " \"publisher\": {\n" - + " \"type\": \"UnconfirmedPublisher\",\n" - + " \"name\": \"My publisher\"\n" - + " },\n" - + " \"date\": {\n" - + " \"type\": \"Instant\",\n" - + " \"value\": \"2022-03-23T00:00:00.000000Z\"\n" - + " },\n" - + " \"sequence\": \"1\"\n" - + "}"}) - void shouldMigrateBroadcastPublishers(String value) { - assertDoesNotThrow(() -> JsonUtils.dtoObjectMapper.readValue(value, Broadcast.class)); - - } - - @ParameterizedTest - @ValueSource(strings = {"{\n" - + " \"type\" : \"OtherRelease\",\n" - + " \"description\" : \"SmM4g4sYfz\",\n" - + " \"place\" : {\n" - + " \"type\" : \"UnconfirmedPlace\",\n" - + " \"label\" : \"dc6zWFBfBcmnzlwN1z\",\n" - + " \"country\" : \"LEQElC2GRpVi75IbqI\"\n" - + " },\n" - + " \"publisher\" : {\n" - + " \"type\" : \"UnconfirmedPublisher\",\n" - + " \"name\" : \"o3XnSxNZkyprTM7DWoQ\"\n" - + " },\n" - + " \"date\" : {\n" - + " \"type\" : \"Instant\",\n" - + " \"value\" : \"2016-01-09T00:59:20.264Z\"\n" - + " },\n" - + " \"sequence\" : 191312365\n" - + "}", - "{\n" - + " \"type\" : \"OtherRelease\",\n" - + " \"description\" : \"SmM4g4sYfz\",\n" - + " \"place\" : {\n" - + " \"type\" : \"UnconfirmedPlace\",\n" - + " \"label\" : \"dc6zWFBfBcmnzlwN1z\",\n" - + " \"country\" : \"LEQElC2GRpVi75IbqI\"\n" - + " },\n" - + " \"publisher\" : \"o3XnSxNZkyprTM7DWoQ\",\n" - + " \"date\" : {\n" - + " \"type\" : \"Instant\",\n" - + " \"value\" : \"2016-01-09T00:59:20.264Z\"\n" - + " },\n" - + " \"sequence\" : 191312365\n" - + "}"}) - void shouldMigrateOtherRelease(String value) { - assertDoesNotThrow(() -> JsonUtils.dtoObjectMapper.readValue(value, OtherRelease.class)); - } - - @ParameterizedTest - @ValueSource(strings = {"{\n" - + " \"type\" : \"AudioVisualPublication\",\n" - + " \"mediaType\" : \"DigitalFile\",\n" - + " \"publisher\" : {\n" - + " \"type\" : \"UnconfirmedPublisher\",\n" - + " \"name\" : \"zqbVxPvPBPY\"\n" - + " },\n" - + " \"catalogueNumber\" : \"qVMAjQwGCTw\",\n" - + " \"trackList\" : [ {\n" - + " \"type\" : \"MusicTrack\",\n" - + " \"title\" : \"prvhN5ATlNDbcAAX0G\",\n" - + " \"composer\" : \"DtePAk2ZjLw8Lzr\",\n" - + " \"extent\" : \"GuJRYj8fAOMcQPQSMI\"\n" - + " }]}", "{\n" - + " \"type\": \"AudioVisualPublication\",\n" - + " \"mediaType\": \"DigitalFile\",\n" - + " \"publisher\": \"UnconfirmedPublisher\",\n" - + " \"catalogueNumber\": \"qVMAjQwGCTw\",\n" - + " \"trackList\": [\n" - + " {\n" - + " \"type\": \"MusicTrack\",\n" - + " \"title\": \"prvhN5ATlNDbcAAX0G\",\n" - + " \"composer\": \"DtePAk2ZjLw8Lzr\",\n" - + " \"extent\": \"GuJRYj8fAOMcQPQSMI\"\n" - + " }\n" - + " ]\n" - + "}"}) - void shouldMigrateAudioVisualPublication(String value) { - assertDoesNotThrow(() -> JsonUtils.dtoObjectMapper.readValue(value, AudioVisualPublication.class)); - } - - @ParameterizedTest - @ValueSource(strings = {"{\n" - + " \"type\" : \"MusicScore\",\n" - + " \"ensemble\" : \"e2d9YoIg1eVxFiTZV\",\n" - + " \"movements\" : \"ID9aYllhE3N5SZ\",\n" - + " \"extent\" : \"26CJRjrfrUqOzP\",\n" - + " \"publisher\" : {\n" - + " \"type\" : \"UnconfirmedPublisher\",\n" - + " \"name\" : \"OVuxPTXnSLd7jcg\"\n" - + " },\n" - + " \"ismn\" : {\n" - + " \"type\" : \"Ismn\",\n" - + " \"value\" : \"M230671187\",\n" - + " \"formatted\" : \"M-2306-7118-7\"\n" - + " },\n" - + " \"isrc\" : {\n" - + " \"type\" : \"Isrc\",\n" - + " \"value\" : \"USRC17607839\"\n" - + " }\n" - + " }", "{\n" - + " \"type\" : \"MusicScore\",\n" - + " \"ensemble\" : \"e2d9YoIg1eVxFiTZV\",\n" - + " \"movements\" : \"ID9aYllhE3N5SZ\",\n" - + " \"extent\" : \"26CJRjrfrUqOzP\",\n" - + " \"publisher\" : \"OVuxPTXnSLd7jcg\",\n" - + " \"ismn\" : {\n" - + " \"type\" : \"Ismn\",\n" - + " \"value\" : \"M230671187\",\n" - + " \"formatted\" : \"M-2306-7118-7\"\n" - + " },\n" - + " \"isrc\" : {\n" - + " \"type\" : \"Isrc\",\n" - + " \"value\" : \"USRC17607839\"\n" - + " }\n" - + "}"}) - void shouldMigratePublisherInMusicScore(String value) { - assertDoesNotThrow(() -> JsonUtils.dtoObjectMapper.readValue(value, MusicScore.class)); - } -} diff --git a/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/book/BookMonographContentTypeTest.java b/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/book/BookMonographContentTypeTest.java deleted file mode 100644 index 8c48c3cc4..000000000 --- a/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/book/BookMonographContentTypeTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package no.unit.nva.model.instancetypes.book; - -import static java.lang.String.format; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.joining; -import static no.unit.nva.model.instancetypes.book.BookMonographContentType.ACADEMIC_MONOGRAPH; -import static no.unit.nva.model.instancetypes.book.BookMonographContentType.DELIMITER; -import static no.unit.nva.model.instancetypes.book.BookMonographContentType.ERROR_MESSAGE_TEMPLATE; -import static no.unit.nva.model.instancetypes.book.BookMonographContentType.NON_FICTION_MONOGRAPH; -import static no.unit.nva.model.instancetypes.book.BookMonographContentType.POPULAR_SCIENCE_MONOGRAPH; -import static no.unit.nva.model.instancetypes.book.BookMonographContentType.values; -import static no.unit.nva.testutils.RandomDataGenerator.randomString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.StringContains.containsString; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.exc.ValueInstantiationException; -import java.util.stream.Stream; -import no.unit.nva.commons.json.JsonUtils; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.function.Executable; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.EnumSource; -import org.junit.jupiter.params.provider.MethodSource; - -class BookMonographContentTypeTest { - - public static Stream deprecatedValuesProvider() { - return Stream.of(Arguments.of("Academic Monograph", ACADEMIC_MONOGRAPH), - Arguments.of("Non-fiction Monograph", NON_FICTION_MONOGRAPH), - Arguments.of("Popular Science Monograph", POPULAR_SCIENCE_MONOGRAPH) - ); - } - - @ParameterizedTest - @EnumSource(BookMonographContentType.class) - void shouldReturnBookMonographContentTypeWhenInputIsCurrentValue(BookMonographContentType bookMonographContentType) - throws JsonProcessingException { - var currentValue = "\"" + bookMonographContentType.getValue() + "\""; - var expectedBookMonographContentType = JsonUtils.dtoObjectMapper.readValue(currentValue, - BookMonographContentType.class); - assertEquals(expectedBookMonographContentType, bookMonographContentType); - } - - @ParameterizedTest(name = "should return BookMonographContentType when input is {0}") - @MethodSource("deprecatedValuesProvider") - void shouldReturnBookMonographContentTypeWhenInputIsDeprecatedValue( - String deprecatedValue, - BookMonographContentType bookMonographContentType) - throws JsonProcessingException { - var deprecated = "\"" + deprecatedValue + "\""; - var expectedBookMonographContentType = JsonUtils.dtoObjectMapper.readValue(deprecated, - BookMonographContentType.class); - assertEquals(expectedBookMonographContentType, bookMonographContentType); - } - - @Test - void shouldThrowErrorWithProperErrorMessageWhenInvalidInputValueSupplied() { - var invalidInput = randomString(); - var inputJsonValue = "\"" + invalidInput + "\""; - Executable handleRequest = () -> JsonUtils.dtoObjectMapper.readValue(inputJsonValue, - BookMonographContentType.class); - - var response = assertThrows(ValueInstantiationException.class, handleRequest); - var actualErrorMessage = createErrorMessage(invalidInput); - assertThat(response.getMessage(), containsString(actualErrorMessage)); - } - - private static String createErrorMessage(String value) { - return format(ERROR_MESSAGE_TEMPLATE, value, stream(values()) - .map(BookMonographContentType::toString).collect(joining(DELIMITER))); - } -} \ No newline at end of file diff --git a/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/chapter/ChapterArticleContentTypeTest.java b/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/chapter/ChapterArticleContentTypeTest.java deleted file mode 100644 index 3de85f3f8..000000000 --- a/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/chapter/ChapterArticleContentTypeTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package no.unit.nva.model.instancetypes.chapter; - -import static java.lang.String.format; -import static java.util.Arrays.stream; -import static java.util.stream.Collectors.joining; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.ACADEMIC_CHAPTER; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.DELIMITER; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.ENCYCLOPEDIA_CHAPTER; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.ERROR_MESSAGE_TEMPLATE; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.EXHIBITION_CATALOG_CHAPTER; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.INTRODUCTION; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.NON_FICTION_CHAPTER; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.POPULAR_SCIENCE_CHAPTER; -import static no.unit.nva.model.instancetypes.chapter.ChapterArticleContentType.TEXTBOOK_CHAPTER; -import static no.unit.nva.testutils.RandomDataGenerator.randomString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.StringContains.containsString; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.exc.ValueInstantiationException; -import java.util.stream.Stream; -import no.unit.nva.commons.json.JsonUtils; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.function.Executable; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.EnumSource; -import org.junit.jupiter.params.provider.MethodSource; - -class ChapterArticleContentTypeTest { - - public static Stream deprecatedValuesProvider() { - return Stream.of( - Arguments.of(ACADEMIC_CHAPTER, "Academic Chapter"), - Arguments.of(NON_FICTION_CHAPTER, "Non-fiction Chapter"), - Arguments.of(POPULAR_SCIENCE_CHAPTER, "Popular Science Chapter"), - Arguments.of(TEXTBOOK_CHAPTER, "Textbook Chapter"), - Arguments.of(ENCYCLOPEDIA_CHAPTER, "Encyclopedia Chapter"), - Arguments.of(INTRODUCTION, "Introduction"), - Arguments.of(EXHIBITION_CATALOG_CHAPTER, "Exhibition Catalog Chapter") - ); - } - - @ParameterizedTest - @EnumSource(ChapterArticleContentType.class) - void shouldReturnChapterArticleContentTypeWhenInputIsCurrentValue( - ChapterArticleContentType chapterArticleContentType) - throws JsonProcessingException { - var currentValue = "\"" + chapterArticleContentType.getValue() + "\""; - var expectedChapterArticleContentType = JsonUtils.dtoObjectMapper.readValue(currentValue, - ChapterArticleContentType.class); - assertEquals(expectedChapterArticleContentType, chapterArticleContentType); - } - - @ParameterizedTest(name = "should return ChapterArticleContentType when input is {0}") - @MethodSource("deprecatedValuesProvider") - void shouldReturnChapterArticleContentTypeWhenInputIsDeprecatedValue( - ChapterArticleContentType chapterArticleContentType,String deprecatedValue) - throws JsonProcessingException { - var deprecated = "\"" + deprecatedValue + "\""; - var expectedChapterArticleContentType = JsonUtils.dtoObjectMapper.readValue(deprecated, - ChapterArticleContentType.class); - assertEquals(expectedChapterArticleContentType, chapterArticleContentType); - } - - @Test - void shouldThrowErrorWithProperErrorMessageWhenInvalidInputValueSupplied() { - var invalidInput = randomString(); - var inputJsonValue = "\"" + invalidInput + "\""; - Executable handleRequest = () -> JsonUtils.dtoObjectMapper.readValue(inputJsonValue, - ChapterArticleContentType.class); - - var response = assertThrows(ValueInstantiationException.class, handleRequest); - var actualErrorMessage = createErrorMessage(invalidInput); - assertThat(response.getMessage(), containsString(actualErrorMessage)); - } - - private static String createErrorMessage(String value) { - return format(ERROR_MESSAGE_TEMPLATE, value, stream(ChapterArticleContentType.values()) - .map(ChapterArticleContentType::toString).collect(joining(DELIMITER))); - } -} \ No newline at end of file diff --git a/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/journal/JournalArticleContentTypeTest.java b/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/journal/JournalArticleContentTypeTest.java deleted file mode 100644 index 26c3a6032..000000000 --- a/nva-datamodel-java/src/test/java/no/unit/nva/model/instancetypes/journal/JournalArticleContentTypeTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package no.unit.nva.model.instancetypes.journal; - -import static no.unit.nva.model.instancetypes.journal.JournalArticleContentType.ACADEMIC_ARTICLE; -import static no.unit.nva.model.instancetypes.journal.JournalArticleContentType.ACADEMIC_LITERATURE_REVIEW; -import static no.unit.nva.model.instancetypes.journal.JournalArticleContentType.CASE_REPORT; -import static no.unit.nva.model.instancetypes.journal.JournalArticleContentType.POPULAR_SCIENCE_ARTICLE; -import static no.unit.nva.model.instancetypes.journal.JournalArticleContentType.PROFESSIONAL_ARTICLE; -import static no.unit.nva.model.instancetypes.journal.JournalArticleContentType.STUDY_PROTOCOL; -import static org.junit.jupiter.api.Assertions.assertEquals; -import com.fasterxml.jackson.core.JsonProcessingException; -import no.unit.nva.commons.json.JsonUtils; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.EnumSource; -import org.junit.jupiter.params.provider.MethodSource; - -import java.util.stream.Stream; - -class JournalArticleContentTypeTest { - - @ParameterizedTest - @EnumSource(JournalArticleContentType.class) - void shouldReturnEnumerationWhenInputIsCurrentName(JournalArticleContentType journalArticleContentType) - throws JsonProcessingException { - var currentValue = "\"" + journalArticleContentType.getValue() + "\""; - var output = JsonUtils.dtoObjectMapper.readValue(currentValue, JournalArticleContentType.class); - assertEquals(output, journalArticleContentType); - } - - @ParameterizedTest(name = "Should return JournalArticleContentType when value is {0}") - @MethodSource("deprecatedJournalArticleContentTypeProvider") - void shouldReturnEnumerationWhenInputIsDeprecatedName(String deprecatedValue, - JournalArticleContentType journalArticleContentType) - throws JsonProcessingException { - var deprecated = "\"" + deprecatedValue + "\""; - var output = JsonUtils.dtoObjectMapper.readValue(deprecated, JournalArticleContentType.class); - assertEquals(output, journalArticleContentType); - } - - public static Stream deprecatedJournalArticleContentTypeProvider() { - return Stream.of( - Arguments.of("Research article", ACADEMIC_ARTICLE), - Arguments.of("Review article", ACADEMIC_LITERATURE_REVIEW), - Arguments.of("Case report", CASE_REPORT), - Arguments.of("Study protocol", STUDY_PROTOCOL), - Arguments.of("Professional article", PROFESSIONAL_ARTICLE), - Arguments.of("Popular science article", POPULAR_SCIENCE_ARTICLE) - ); - } -} \ No newline at end of file diff --git a/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationContextBuilder.java b/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationContextBuilder.java index 534329a4a..ee464973e 100644 --- a/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationContextBuilder.java +++ b/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationContextBuilder.java @@ -65,7 +65,6 @@ public static PublicationContext randomPublicationContext(Class publicationIn case "ConferenceAbstract": case "FeatureArticle": case "JournalCorrigendum": - case "JournalArticle": case "AcademicArticle": case "AcademicLiteratureReview": case "CaseReport": @@ -85,7 +84,6 @@ public static PublicationContext randomPublicationContext(Class publicationIn case "Textbook": case "BookAnthology": case "BookAbstracts": - case "BookMonograph": case "OtherStudentWork": return attempt(PublicationContextBuilder::randomBook).orElseThrow(); case "DegreeBachelor": @@ -93,7 +91,6 @@ public static PublicationContext randomPublicationContext(Class publicationIn case "DegreePhd": case "DegreeLicentiate": return attempt(PublicationContextBuilder::randomDegree).orElseThrow(); - case "ChapterArticle": case "AcademicChapter": case "NonFictionChapter": case "PopularScienceChapter": diff --git a/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationInstanceBuilder.java b/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationInstanceBuilder.java index ea83b0762..9f6c1d89e 100644 --- a/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationInstanceBuilder.java +++ b/nva-datamodel-testutils/src/main/java/no/unit/nva/model/testing/PublicationInstanceBuilder.java @@ -177,7 +177,6 @@ public static PublicationInstance randomPublicationInstance(Cla return generateFeatureArticle(); case "JournalCorrigendum": return generateJournalCorrigendum(); - case "JournalArticle": case "AcademicArticle": return generateAcademicArticle(); case "AcademicLiteratureReview": @@ -192,7 +191,6 @@ public static PublicationInstance randomPublicationInstance(Cla return generatePopularScienceArticle(); case "BookAnthology": return generateBookAnthology(); - case "ChapterArticle": case "AcademicChapter": return generateAcademicChapter(); case "NonFictionChapter": @@ -221,7 +219,6 @@ public static PublicationInstance randomPublicationInstance(Cla return generateJournalReview(); case "BookAbstracts": return generateBookAbstracts(); - case "BookMonograph": case "AcademicMonograph": return generateAcademicMonograph(); case "NonFictionMonograph":