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

spring injection added

parent 8e33399a
No related branches found
No related tags found
1 merge request!106Resolve "project query shouldn't return data about models"
......@@ -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"/>
......
......@@ -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 {
......
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;
}
}
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