Search in sources :

Example 1 with InMemoryDSWDatasourceServiceImpl

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);
}
Also used : TestObjectFactory(org.pentaho.platform.engine.core.TestObjectFactory) InMemoryDSWDatasourceServiceImpl(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.InMemoryDSWDatasourceServiceImpl) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)1 InMemoryDSWDatasourceServiceImpl (org.pentaho.platform.dataaccess.datasource.wizard.service.impl.InMemoryDSWDatasourceServiceImpl)1 TestObjectFactory (org.pentaho.platform.engine.core.TestObjectFactory)1