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");
}
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());
}
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();
}
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());
}
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());
}
Aggregations