Search in sources :

Example 1 with DataServiceAlreadyExistsException

use of org.pentaho.di.trans.dataservice.serialization.DataServiceAlreadyExistsException in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceDialogControllerTest method testError.

@Test
public void testError() throws Exception {
    UndefinedDataServiceException undefinedException = new UndefinedDataServiceException(dataServiceMeta);
    doThrow(undefinedException).doReturn(dataServiceMeta).when(delegate).checkDefined(dataServiceMeta);
    DataServiceAlreadyExistsException alreadyExistsException = new DataServiceAlreadyExistsException(dataServiceMeta);
    doThrow(alreadyExistsException).doReturn(dataServiceMeta).when(delegate).checkConflict(dataServiceMeta, null);
    MetaStoreException metaStoreException = new MetaStoreException();
    doThrow(metaStoreException).doNothing().when(delegate).save(dataServiceMeta);
    controller.saveAndClose();
    verify(messageBox).setMessage(undefinedException.getMessage());
    controller.saveAndClose();
    verify(messageBox).setMessage(alreadyExistsException.getMessage());
    verify(delegate, never()).save(any(DataServiceMeta.class));
    controller.saveAndClose();
    verify(messageBox, times(3)).open();
    verify(logChannel).logError(anyString(), same(metaStoreException));
    verify(dialog, never()).dispose();
    controller.saveAndClose();
    verify(dialog).dispose();
    verifyNoMoreInteractions(logChannel);
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UndefinedDataServiceException(org.pentaho.di.trans.dataservice.serialization.UndefinedDataServiceException) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) DataServiceAlreadyExistsException(org.pentaho.di.trans.dataservice.serialization.DataServiceAlreadyExistsException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)1 DataServiceAlreadyExistsException (org.pentaho.di.trans.dataservice.serialization.DataServiceAlreadyExistsException)1 UndefinedDataServiceException (org.pentaho.di.trans.dataservice.serialization.UndefinedDataServiceException)1 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)1