DataServiceMetaStoreUtil { public DataServiceMeta checkDefined( DataServiceMeta dataServiceMeta ) throws UndefinedDataServiceException { if ( Strings.isNullOrEmpty( dataServiceMeta.getName() ) ) { throw new UndefinedDataServiceException( dataServiceMeta, getString( PKG, "Messages.SaveError.NameMissing" ) ); } if ( Strings.isNullOrEmpty( dataServiceMeta.getStepname() ) ) { throw new UndefinedDataServiceException( dataServiceMeta, getString( PKG, "Messages.SaveError.StepMissing" ) ); } if ( dataServiceMeta.getServiceTrans().findStep( dataServiceMeta.getStepname() ) == null ) { throw new UndefinedDataServiceException( dataServiceMeta, getString( PKG, "Messages.SaveError.StepNotFound", dataServiceMeta.getStepname() ) ); } return dataServiceMeta; } protected  DataServiceMetaStoreUtil( DataServiceContext context, Cache<Integer, String> cache ); protected  DataServiceMetaStoreUtil( DataServiceMetaStoreUtil metaStoreUtil ); static DataServiceMetaStoreUtil create( DataServiceContext context ); DataServiceMeta getDataService( String serviceName, Repository repository, IMetaStore metaStore ); DataServiceMeta getDataService( String serviceName, TransMeta serviceTrans ); Iterable<DataServiceMeta> getDataServices( final Repository repository, IMetaStore metaStore,
                                                    final Function<Exception, Void> exceptionHandler ); Iterable<DataServiceMeta> getDataServices( TransMeta transMeta ); List<String> getDataServiceNames( TransMeta transMeta ); List<String> getDataServiceNames( IMetaStore metaStore ); DataServiceMeta getDataServiceByStepName( TransMeta transMeta, String stepName ); DataServiceMeta checkDefined( DataServiceMeta dataServiceMeta ); DataServiceMeta checkConflict( DataServiceMeta dataServiceMeta, String ignored ); void save( DataServiceMeta dataService ); void removeDataService( DataServiceMeta dataService ); void deleteDataServiceElementAndCleanCache( DataServiceMeta dataService, TransMeta transMeta ); @Deprecated( ) void sync( TransMeta transMeta, Function<? super Exception, ?> exceptionHandler ); ImmutableMap<String, ServiceTrans> getServiceTransMap( TransMeta transMeta ); void clearReferences( TransMeta transMeta ); LogChannelInterface getLogChannel(); List<PushDownFactory> getPushDownFactories(); Function<Exception, Void> logErrors( final String message ); DataServiceContext getContext(); Cache<Integer, String> getStepCache();  }
@Test public void testCheckDefined() throws Exception { metaStoreUtil.checkDefined( dataService ); try { dataService.setName( "" ); metaStoreUtil.checkDefined( dataService ); fail( "Expected failure for empty name" ); } catch ( UndefinedDataServiceException e ) { assertThat( e.getDataServiceMeta(), sameInstance( dataService ) ); } dataService = metaStoreUtil.checkDefined( createDataService( DATA_SERVICE_NAME, transMeta ) ); try { dataService.setStepname( "" ); metaStoreUtil.checkDefined( dataService ); fail( "Expected failure for empty step name" ); } catch ( UndefinedDataServiceException e ) { assertThat( e.getDataServiceMeta(), sameInstance( dataService ) ); } dataService = metaStoreUtil.checkDefined( createDataService( DATA_SERVICE_NAME, transMeta ) ); try { dataService.setStepname( "Not in Trans" ); metaStoreUtil.checkDefined( dataService ); fail( "Expected failure for non-existant step name" ); } catch ( UndefinedDataServiceException e ) { assertThat( e.getDataServiceMeta(), sameInstance( dataService ) ); } }