use of org.pentaho.platform.engine.core.TestObjectFactory in project data-access by pentaho.
the class DatasourceModelTest method testDatasourceDTOSerialization.
@Test
public void testDatasourceDTOSerialization() throws Exception {
PentahoSystem.registerObjectFactory(new TestObjectFactory());
DatasourceModel datasourceModel = spy(new DatasourceModel());
doReturn("testdatasource").when(datasourceModel).generateTableName();
datasourceModel.setDatasourceName("testDatasource");
datasourceModel.setDatasourceType(DatasourceType.SQL);
datasourceModel.setGuiStateModel(contructRelationalModel(datasourceModel.getGuiStateModel()));
datasourceModel.setSelectedRelationalConnection(datasourceModel.getGuiStateModel().getConnections().get(0));
DatasourceDTO dto = DatasourceDTO.generateDTO(datasourceModel);
assertNotNull(dto);
InMemoryDSWDatasourceServiceImpl service = new InMemoryDSWDatasourceServiceImpl();
String dtoString = service.serializeModelState(dto);
assertNotNull(dtoString);
assertTrue(dtoString.contains("testDatasource"));
DatasourceDTO dto2 = service.deSerializeModelState(dtoString);
assertEquals(dto, dto2);
}
use of org.pentaho.platform.engine.core.TestObjectFactory in project data-access by pentaho.
the class DSWDatasourceServiceImplTest method testDeSerializeModelStateValidString.
@Test
public void testDeSerializeModelStateValidString() throws Exception {
PentahoSystem.registerObjectFactory(new TestObjectFactory());
DatasourceModel datasourceModel = spy(new DatasourceModel());
doReturn("testdatasource").when(datasourceModel).generateTableName();
datasourceModel.setDatasourceName("testDatasource");
datasourceModel.setDatasourceType(DatasourceType.CSV);
DatasourceDTO dto = DatasourceDTO.generateDTO(datasourceModel);
assertNotNull(dto);
String serializedDTO = dswService.serializeModelState(dto);
dswService.deSerializeModelState(serializedDTO);
}
Aggregations