Search in sources :

Example 51 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class ExportTXTHeaderTest method shouldContainTheNumberOfEntriesInTheHeader.

// TEST for https://issues.isb-sib.ch/browse/CALIPHOMISC-330
@Test
public void shouldContainTheNumberOfEntriesInTheHeader() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Writer writer = new PrintWriter(out);
    EntryVelocityBasedStreamWriter exporter = new EntryTXTStreamWriter(writer);
    exporter.setEntryBuilderService(entryBuilderMockService);
    when(entryBuilderMockService.build(any(EntryConfig.class))).thenReturn(new Entry("NX_1")).thenReturn(new Entry("NX_2"));
    Map<String, Object> infos = new HashMap<>();
    infos.put(EntryStreamWriter.getReleaseInfoKey(), Mockito.mock(ReleaseInfoVersions.class));
    exporter.write(Arrays.asList("NX_1", "NX_2"), infos);
    String[] rows = out.toString().split(StringUtils.CR_LF);
    assertEquals(rows[0], "#nb entries=2");
    assertEquals(rows[1], "NX_1");
    assertEquals(rows[2], "NX_2");
}
Also used : Entry(org.nextprot.api.core.domain.Entry) ReleaseInfoVersions(org.nextprot.api.core.domain.release.ReleaseInfoVersions) EntryTXTStreamWriter(org.nextprot.api.web.service.impl.writer.EntryTXTStreamWriter) HashMap(java.util.HashMap) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EntryVelocityBasedStreamWriter(org.nextprot.api.web.service.impl.writer.EntryVelocityBasedStreamWriter) PrintWriter(java.io.PrintWriter) EntryTXTStreamWriter(org.nextprot.api.web.service.impl.writer.EntryTXTStreamWriter) EntryVelocityBasedStreamWriter(org.nextprot.api.web.service.impl.writer.EntryVelocityBasedStreamWriter) Writer(java.io.Writer) EntryStreamWriter(org.nextprot.api.web.service.impl.writer.EntryStreamWriter) PrintWriter(java.io.PrintWriter) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 52 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class EntryOverviewXMLUnitTest method shouldContainOverviewWithGeneNameList.

// Tests issue CALIPHOMISC-330
// https://issues.isb-sib.ch/browse/CALIPHOMISC-330
@Test
public void shouldContainOverviewWithGeneNameList() throws Exception {
    // Create an entry for test purposes
    Entry entry = new Entry("my-test-entry");
    Overview overview = new Overview();
    entry.setOverview(overview);
    List<EntityName> names = new ArrayList<EntityName>();
    overview.setGeneNames(names);
    EntityName mainName = new EntityName();
    mainName.setMain(true);
    mainName.setName("ABCD");
    EntityName synonym = new EntityName();
    synonym.setMain(false);
    synonym.setName("EFGH");
    EntityName orf = new EntityName();
    orf.setMain(false);
    orf.setName("IJKL");
    orf.setCategory("ORF");
    mainName.addAllSynonyms(Arrays.asList(synonym, orf));
    names.add(mainName);
    // Gets the velocity output
    String output = this.getVelocityOutput(entry);
    NodeList nodes = XMLUnitUtils.getMatchingNodes(output, "entry/overview");
    assertEquals(1, nodes.getLength());
    // Test the content using xmlunit
    NodeList recommendedNodes = XMLUnitUtils.getMatchingNodes(output, "entry/overview/gene-list/gene/gene-name[@type='primary']");
    assertEquals("ABCD", recommendedNodes.item(0).getTextContent());
    NodeList alternativeNodeList = XMLUnitUtils.getMatchingNodes(output, "entry/overview/gene-list/gene/gene-name[@type='synonym']");
    assertEquals("EFGH", alternativeNodeList.item(0).getTextContent());
    NodeList orfNodeList = XMLUnitUtils.getMatchingNodes(output, "entry/overview/gene-list/gene/gene-name[@type='ORF']");
    assertEquals("IJKL", orfNodeList.item(0).getTextContent());
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntityName(org.nextprot.api.core.domain.EntityName) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) Overview(org.nextprot.api.core.domain.Overview) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Example 53 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class EntryConverter method marshal.

public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    Entry entry = (Entry) value;
    writer.startNode("fullname");
    writer.addAttribute("yo", "yeah");
    writer.setValue(entry.getUniqueName());
    writer.endNode();
    if (entry.getIsoforms() != null) {
        writer.startNode("isoform-list");
        context.convertAnother(entry.getIsoforms());
        writer.endNode();
    }
    if (entry.getPublications() != null) {
        writer.startNode("publication-list");
        context.convertAnother(entry.getPublications());
        writer.endNode();
    }
    if (entry.getXrefs() != null) {
        writer.startNode("xref-list");
        context.convertAnother(entry.getXrefs());
        writer.endNode();
    }
    writer.startNode("annotation-list");
    context.convertAnother(entry.getAnnotations());
    writer.endNode();
}
Also used : Entry(org.nextprot.api.core.domain.Entry)

Example 54 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class SequenceVariantTest method testGetIsoformIso.

@Test
public void testGetIsoformIso() throws Exception {
    SequenceVariant variant = new SequenceVariant("SCN11A-iso2-p.Leu1158Pro");
    Entry entry = mockEntry("NX_P06213", mockIsoform("NX_Q9UI33-1", "Iso 1", true), mockIsoform("NX_Q9UI33-2", "Iso 2", false), mockIsoform("NX_Q9UI33-3", "Iso 3", false));
    Assert.assertEquals("NX_Q9UI33-2", variant.getIsoform(entry).getUniqueName());
    Assert.assertEquals("Iso 2", variant.getIsoformName());
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Test(org.junit.Test)

Example 55 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class SequenceVariantTest method testGetIsoformNonIsoCanonical.

@Test
public void testGetIsoformNonIsoCanonical() throws Exception {
    SequenceVariant variant = new SequenceVariant("INSR-p.Arg113Pro");
    Entry entry = mockEntry("NX_P06213", mockIsoform("NX_P06213-1", "Long", true), mockIsoform("NX_P06213-2", "Short", false));
    Assert.assertEquals("NX_P06213-1", variant.getIsoform(entry).getUniqueName());
    Assert.assertNull(variant.getIsoformName());
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Test(org.junit.Test)

Aggregations

Entry (org.nextprot.api.core.domain.Entry)60 Test (org.junit.Test)38 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)16 Annotation (org.nextprot.api.core.domain.annotation.Annotation)9 Isoform (org.nextprot.api.core.domain.Isoform)8 EntryConfig (org.nextprot.api.core.service.fluent.EntryConfig)8 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)8 EntryBuilderService (org.nextprot.api.core.service.EntryBuilderService)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Assert (org.junit.Assert)4 Ignore (org.junit.Ignore)4 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)4 DbXref (org.nextprot.api.core.domain.DbXref)4 ArrayList (java.util.ArrayList)3 PropertyApiModel (org.nextprot.api.commons.constants.PropertyApiModel)3 SolrDiffTest (org.nextprot.api.tasks.solr.indexer.entry.SolrDiffTest)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 java.util (java.util)2