Skip to content
Snippets Groups Projects
Commit 22ed3e09 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

type for annotationView resolved properly

parent 246de1df
No related branches found
No related tags found
1 merge request!57References rest result improved
......@@ -95,7 +95,7 @@ public abstract class BaseRestImpl {
protected Map<String, Object> createAnnotation(AnnotationView annotation) {
Map<String, Object> result = new HashMap<>();
if (annotation != null && annotation.getType() != null) {
MiriamType type = MiriamType.getTypeByCommonName(annotation.getName());
MiriamType type = MiriamType.getTypeByCommonName(annotation.getType());
result.put("link", annotation.getLink());
if (MiriamType.PUBMED.equals(type)) {
try {
......
......@@ -4,12 +4,14 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import lcsb.mapviewer.api.projects.drugs.AllDrugTests;
import lcsb.mapviewer.api.projects.models.AllModelsTests;
import lcsb.mapviewer.api.projects.overlays.AllOverlaysTests;
@RunWith(Suite.class)
@SuiteClasses({ AllModelsTests.class, //
AllOverlaysTests.class, //
@SuiteClasses({ AllDrugTests.class, //
AllModelsTests.class, //
AllOverlaysTests.class, //
ModelMetaDataTest.class, //
ProjectRestImplTest.class })
public class AllProjectTests {
......
package lcsb.mapviewer.api.projects.drugs;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ DrugRestImplTest.class })
public class AllDrugTests {
}
package lcsb.mapviewer.api.projects.drugs;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.api.RestTestFunctions;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.services.interfaces.IModelService;
public class DrugRestImplTest extends RestTestFunctions {
Logger logger = Logger.getLogger(DrugRestImplTest.class);
@Autowired
private DrugRestImpl _drugRestImpl;
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
@SuppressWarnings("unchecked")
public void testGetModelAsImage() throws Exception {
try {
DrugRestImpl drugRestImpl = createMockProjectRest("testFiles/model/sample.xml");
Map<String, Object> result = drugRestImpl.getDrugsByQuery(token.getId(), "sample", "", "nadh").get(0);
List<Map<String, Object>> references = (List<Map<String, Object>>) result.get("references");
Map<String, Object> reference = references.get(0);
assertNotNull(reference.get("type"));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
private DrugRestImpl createMockProjectRest(String string) throws Exception {
Model model = super.getModelForFile(string, true);
IModelService mockModelService = Mockito.mock(IModelService.class);
Mockito.when(mockModelService.getLastModelByProjectId(anyString(), any())).thenReturn(model);
_drugRestImpl.setModelService(mockModelService);
return _drugRestImpl;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment