diff --git a/rest-api/src/main/resources/applicationContext-rest.xml b/rest-api/src/main/resources/applicationContext-rest.xml index 5cbacb6fc6473c8ce69a2acb2117cc956ad83528..2642267ee9757e4925f78b5142c8022365264033 100644 --- a/rest-api/src/main/resources/applicationContext-rest.xml +++ b/rest-api/src/main/resources/applicationContext-rest.xml @@ -15,6 +15,7 @@ <bean id="CommentRestImpl" class="lcsb.mapviewer.api.projects.comments.CommentRestImpl"/> <bean id="ProjectRestImpl" class="lcsb.mapviewer.api.projects.ProjectRestImpl"/> + <bean id="ModelRestImpl" class="lcsb.mapviewer.api.projects.models.ModelRestImpl"/> <bean id="BioEntitiesRestImpl" class="lcsb.mapviewer.api.projects.models.bioEntities.BioEntitiesRestImpl"/> <bean id="ChemicalRestImpl" class="lcsb.mapviewer.api.projects.chemicals.ChemicalRestImpl"/> <bean id="ElementsRestImpl" class="lcsb.mapviewer.api.projects.models.bioEntities.elements.ElementsRestImpl"/> diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java index 58bce555cf36a931dfc0b2cc6857edcb846f6004..3cb26a74c6f9c5eded78255a02e75de3bd9b137f 100644 --- a/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/AllModelsTests.java @@ -10,7 +10,8 @@ import lcsb.mapviewer.api.projects.models.publications.AllPublicationsTests; @RunWith(Suite.class) @SuiteClasses({ // AllBioeEntitiesTests.class, // - AllPublicationsTests.class// + AllPublicationsTests.class, // + ModelRestImplTest.class,// }) public class AllModelsTests { diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/ModelRestImplTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/ModelRestImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8340abe87ecc4061b61e2ab7a6dcd37e9a994217 --- /dev/null +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/models/ModelRestImplTest.java @@ -0,0 +1,58 @@ +package lcsb.mapviewer.api.projects.models; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; + +import java.util.List; +import java.util.Map; + +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 ModelRestImplTest extends RestTestFunctions { + + @Autowired + ModelRestImpl _projectRestImpl; + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testModels() throws Exception { + try { + ModelRestImpl modelRest = createMockProjectRest("testFiles/model/sample.xml"); + List<ModelMetaData> result = modelRest.getModels("sample", token.getId()); + assertEquals(1, result.size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + private ModelRestImpl 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); + _projectRestImpl.setModelService(mockModelService); + return _projectRestImpl; + } + +}