From f99e4f116d0df52ae4b1e64e888763c2f5ac6b95 Mon Sep 17 00:00:00 2001 From: supun Date: Wed, 4 Oct 2023 16:03:10 +0100 Subject: [PATCH] add defualt constructor to proteome stats --- .../proteome/impl/ProteomeStatisticsImpl.java | 9 ++++- .../impl/ProteomeStatisticsImplTest.java | 12 +++++- .../parser/proteome/ProteomeJsonConfig.java | 39 ++++--------------- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java index 3f425e4b1..7af954e5d 100644 --- a/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java +++ b/core-domain/src/main/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImpl.java @@ -1,11 +1,12 @@ package org.uniprot.core.proteome.impl; -import java.util.Objects; - import org.uniprot.core.impl.StatisticsImpl; import org.uniprot.core.proteome.ProteomeStatistics; +import java.util.Objects; + public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeStatistics { + private static final long serialVersionUID = -8585233468042758658L; private final long isoformProteinCount; ProteomeStatisticsImpl( @@ -14,6 +15,10 @@ public class ProteomeStatisticsImpl extends StatisticsImpl implements ProteomeSt this.isoformProteinCount = isoformProteinCount; } + ProteomeStatisticsImpl() { + this(0, 0,0); + } + @Override public long getIsoformProteinCount() { return isoformProteinCount; diff --git a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java index e4e27baf5..e1e3edcae 100644 --- a/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java +++ b/core-domain/src/test/java/org/uniprot/core/proteome/impl/ProteomeStatisticsImplTest.java @@ -1,9 +1,10 @@ package org.uniprot.core.proteome.impl; -import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + class ProteomeStatisticsImplTest { public static final int REVIEWED_PROTEIN_COUNT = 98; public static final int UNREVIEWED_PROTEIN_COUNT = 33; @@ -20,6 +21,13 @@ void getCountsAreAccurate() { assertEquals(ISOFORM_PROTEIN_COUNT, PROTEOME_STATISTICS.getIsoformProteinCount()); } + @Test + void defaultConstructor() { + ProteomeStatisticsImpl that = + new ProteomeStatisticsImpl(); + assertEquals(new ProteomeStatisticsImpl(0, 0, 0), that); + } + @Test void equals_whenTrue() { ProteomeStatisticsImpl that = diff --git a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java index 9040fee57..20b2115e8 100644 --- a/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java +++ b/json-parser/src/main/java/org/uniprot/core/json/parser/proteome/ProteomeJsonConfig.java @@ -1,41 +1,19 @@ package org.uniprot.core.json.parser.proteome; -import java.time.LocalDate; - +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.jsontype.NamedType; +import com.fasterxml.jackson.databind.module.SimpleModule; import org.uniprot.core.CrossReference; import org.uniprot.core.Database; import org.uniprot.core.Value; -import org.uniprot.core.citation.Author; -import org.uniprot.core.citation.Book; -import org.uniprot.core.citation.ElectronicArticle; -import org.uniprot.core.citation.Journal; -import org.uniprot.core.citation.JournalArticle; -import org.uniprot.core.citation.Locator; -import org.uniprot.core.citation.Patent; -import org.uniprot.core.citation.PublicationDate; -import org.uniprot.core.citation.Submission; -import org.uniprot.core.citation.Thesis; -import org.uniprot.core.citation.Unpublished; -import org.uniprot.core.citation.impl.AuthorImpl; -import org.uniprot.core.citation.impl.BookImpl; -import org.uniprot.core.citation.impl.ElectronicArticleImpl; -import org.uniprot.core.citation.impl.JournalArticleImpl; -import org.uniprot.core.citation.impl.JournalImpl; -import org.uniprot.core.citation.impl.PatentImpl; -import org.uniprot.core.citation.impl.PublicationDateImpl; -import org.uniprot.core.citation.impl.SubmissionImpl; -import org.uniprot.core.citation.impl.ThesisImpl; -import org.uniprot.core.citation.impl.UnpublishedImpl; +import org.uniprot.core.citation.*; +import org.uniprot.core.citation.impl.*; import org.uniprot.core.impl.CrossReferenceImpl; import org.uniprot.core.impl.DefaultDatabase; import org.uniprot.core.impl.ValueImpl; import org.uniprot.core.json.parser.JsonConfig; import org.uniprot.core.json.parser.deserializer.LocalDateDeserializer; -import org.uniprot.core.json.parser.serializer.AuthorSerializer; -import org.uniprot.core.json.parser.serializer.JournalSerializer; -import org.uniprot.core.json.parser.serializer.LocalDateSerializer; -import org.uniprot.core.json.parser.serializer.LocatorSerializer; -import org.uniprot.core.json.parser.serializer.PublicationDateSerializer; +import org.uniprot.core.json.parser.serializer.*; import org.uniprot.core.json.parser.uniprot.serializer.UniProtKBAccessionSerializer; import org.uniprot.core.proteome.*; import org.uniprot.core.proteome.impl.*; @@ -46,9 +24,7 @@ import org.uniprot.core.uniprotkb.taxonomy.Taxonomy; import org.uniprot.core.uniprotkb.taxonomy.impl.TaxonomyImpl; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.module.SimpleModule; +import java.time.LocalDate; public class ProteomeJsonConfig extends JsonConfig { private static ProteomeJsonConfig instance; @@ -89,6 +65,7 @@ private ObjectMapper initObjectMapper() { mod.addAbstractTypeMapping(ProteomeId.class, ProteomeIdImpl.class); mod.addAbstractTypeMapping(Taxonomy.class, TaxonomyImpl.class); mod.addAbstractTypeMapping(TaxonomyLineage.class, TaxonomyLineageImpl.class); + mod.addAbstractTypeMapping(ProteomeStatistics.class, ProteomeStatisticsImpl.class); mod.addAbstractTypeMapping(Value.class, ValueImpl.class); mod.addAbstractTypeMapping(RedundantProteome.class, RedundantProteomeImpl.class);