use of org.pentaho.platform.dataaccess.datasource.wizard.service.impl.InMemoryDSWDatasourceServiceImpl 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);
}
Aggregations