method2testcases
stringlengths 118
3.08k
|
---|
### Question:
TransFileListener implements FileListener { public String getRootNodeName() { return "transformation"; } boolean open( Node transNode, String fname, boolean importfile ); boolean save( EngineMetaInterface meta, String fname, boolean export ); void syncMetaName( EngineMetaInterface meta, String name ); boolean accepts( String fileName ); boolean acceptsXml( String nodeName ); String[] getFileTypeDisplayNames( Locale locale ); String getRootNodeName(); String[] getSupportedExtensions(); }### Answer:
@Test public void testGetRootNodeName() throws Exception { assertEquals( "transformation", transFileListener.getRootNodeName() ); } |
### Question:
TransFileListener implements FileListener { public String[] getSupportedExtensions() { return new String[]{ "ktr", "xml" }; } boolean open( Node transNode, String fname, boolean importfile ); boolean save( EngineMetaInterface meta, String fname, boolean export ); void syncMetaName( EngineMetaInterface meta, String name ); boolean accepts( String fileName ); boolean acceptsXml( String nodeName ); String[] getFileTypeDisplayNames( Locale locale ); String getRootNodeName(); String[] getSupportedExtensions(); }### Answer:
@Test public void testGetSupportedExtensions() throws Exception { String[] extensions = transFileListener.getSupportedExtensions(); assertNotNull( extensions ); assertEquals( 2, extensions.length ); assertEquals( "ktr", extensions[0] ); assertEquals( "xml", extensions[1] ); } |
### Question:
JobEntryTransDialog extends JobEntryBaseDialog implements JobEntryDialogInterface { String getEntryName( String name ) { return "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + name; } JobEntryTransDialog( Shell parent, JobEntryInterface jobEntryInt, Repository rep, JobMeta jobMeta ); JobEntryInterface open(); void dispose(); void getData(); }### Answer:
@Test public void testEntryName() { dialog = mock( JobEntryTransDialog.class ); doCallRealMethod().when( dialog ).getEntryName( any() ); assertEquals( dialog.getEntryName( FILE_NAME ), "${Internal.Entry.Current.Directory}/" + FILE_NAME ); } |
### Question:
JobEntryJobDialog extends JobEntryBaseDialog implements JobEntryDialogInterface { String getEntryName( String name ) { return "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + name; } JobEntryJobDialog( Shell parent, JobEntryInterface jobEntryInt, Repository rep, JobMeta jobMeta ); JobEntryInterface open(); void dispose(); void setActive(); void getData(); void ok(); }### Answer:
@Test public void testEntryName() { dialog = mock( JobEntryJobDialog.class ); doCallRealMethod().when( dialog ).getEntryName( any() ); assertEquals( dialog.getEntryName( FILE_NAME ), "${Internal.Entry.Current.Directory}/" + FILE_NAME ); } |
### Question:
RulesExecutorData extends BaseStepData implements StepDataInterface { public void loadRow( Object[] r ) { for ( int i = 0; i < columnList.length; i++ ) { columnList[i].setPayload( r[i] ); } resultMap.clear(); } String getRuleString(); void setRuleString( String ruleString ); String getRuleFilePath(); void setRuleFilePath( String ruleFilePath ); void setOutputRowMeta( RowMetaInterface outputRowMeta ); RowMetaInterface getOutputRowMeta(); void initializeRules(); void initializeColumns( RowMetaInterface inputRowMeta ); void loadRow( Object[] r ); void execute(); Object fetchResult( String columnName ); void shutdown(); }### Answer:
@Test public void testLoadRow() throws Exception { data.loadRow( new Object[] { "1", "2" } ); data.execute(); data.loadRow( new Object[] { "3", "4" } ); assertEquals( null, data.fetchResult( "c1" ) ); assertEquals( null, data.fetchResult( "c2" ) ); } |
### Question:
MetaInject extends BaseStep implements StepInterface { static Set<String> convertToUpperCaseSet( String[] array ) { if ( array == null ) { return Collections.emptySet(); } Set<String> strings = new HashSet<String>(); for ( String currentString : array ) { strings.add( currentString.toUpperCase() ); } return strings; } MetaInject( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi ); static void removeUnavailableStepsFromMapping( Map<TargetStepAttribute, SourceStepField> targetMap,
Set<SourceStepField> unavailableSourceSteps, Set<TargetStepAttribute> unavailableTargetSteps ); static Set<TargetStepAttribute> getUnavailableTargetSteps( Map<TargetStepAttribute, SourceStepField> targetMap,
TransMeta injectedTransMeta ); static Set<TargetStepAttribute> getUnavailableTargetKeys( Map<TargetStepAttribute, SourceStepField> targetMap,
TransMeta injectedTransMeta, Set<TargetStepAttribute> unavailableTargetSteps ); static Set<SourceStepField> getUnavailableSourceSteps( Map<TargetStepAttribute, SourceStepField> targetMap,
TransMeta sourceTransMeta, StepMeta stepMeta ); }### Answer:
@Test public void convertToUpperCaseSet_null_array() { Set<String> actualResult = MetaInject.convertToUpperCaseSet( null ); assertNotNull( actualResult ); assertTrue( actualResult.isEmpty() ); }
@Test public void convertToUpperCaseSet() { String[] input = new String[] { "Test_Step", "test_step1" }; Set<String> actualResult = MetaInject.convertToUpperCaseSet( input ); Set<String> expectedResult = new HashSet<>(); expectedResult.add( "TEST_STEP" ); expectedResult.add( "TEST_STEP1" ); assertEquals( expectedResult, actualResult ); } |
### Question:
OpenMappingExtension implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException { StepMeta stepMeta = (StepMeta) ( (Object[]) object )[ 0 ]; TransMeta transMeta = (TransMeta) ( (Object[]) object )[ 1 ]; if ( stepMeta.getStepMetaInterface() instanceof MetaInjectMeta ) { transMeta.setFilename( null ); transMeta.setObjectId( null ); String appendName = " (" + BaseMessages.getString( PKG, "TransGraph.AfterInjection" ) + ")"; if ( !transMeta.getName().endsWith( appendName ) ) { transMeta.setName( transMeta.getName() + appendName ); } } } @Override void callExtensionPoint( LogChannelInterface log, Object object ); }### Answer:
@Test public void testLocalizedMessage() throws KettleException { OpenMappingExtension openMappingExtension = new OpenMappingExtension(); Class PKG = SpoonLifecycleListener.class; String afterInjectionMessageAdded = BaseMessages.getString( PKG, "TransGraph.AfterInjection" ); transMeta.setName( TRANS_META_NAME ); doReturn( mock( MetaInjectMeta.class ) ).when( stepMeta ).getStepMetaInterface(); openMappingExtension.callExtensionPoint( logChannelInterface, metaData ); assert ( transMeta.getName().contains( afterInjectionMessageAdded ) ); } |
### Question:
MetaInjectMigration { public static void migrateFrom70( Map<TargetStepAttribute, SourceStepField> targetSourceMapping ) { for ( TargetStepAttribute target : new ArrayList<>( targetSourceMapping.keySet() ) ) { if ( "SCHENAMENAMEFIELD".equals( target.getAttributeKey() ) ) { SourceStepField so = targetSourceMapping.remove( target ); TargetStepAttribute target2 = new TargetStepAttribute( target.getStepname(), "SCHEMANAMEFIELD", target.isDetail() ); targetSourceMapping.put( target2, so ); } } } static void migrateFrom70( Map<TargetStepAttribute, SourceStepField> targetSourceMapping ); }### Answer:
@Test public void test70() { Map<TargetStepAttribute, SourceStepField> targetSourceMapping = new HashMap<>(); TargetStepAttribute target = new TargetStepAttribute( "step", "SCHENAMENAMEFIELD", true ); SourceStepField source = new SourceStepField( "step", "field" ); targetSourceMapping.put( target, source ); MetaInjectMigration.migrateFrom70( targetSourceMapping ); assertEquals( 1, targetSourceMapping.size() ); TargetStepAttribute target2 = targetSourceMapping.keySet().iterator().next(); assertEquals( "SCHEMANAMEFIELD", target2.getAttributeKey() ); assertEquals( target.getStepname(), target2.getStepname() ); assertEquals( target.isDetail(), target2.isDetail() ); assertEquals( source, targetSourceMapping.get( target2 ) ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override public String getResourceInputNodeType() { return DictionaryConst.NODE_TYPE_FILE_FIELD; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testGetResourceInputNodeType() throws Exception { assertEquals( DictionaryConst.NODE_TYPE_FILE_FIELD, analyzer.getResourceInputNodeType() ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override public String getResourceOutputNodeType() { return null; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testGetResourceOutputNodeType() throws Exception { assertNull( analyzer.getResourceOutputNodeType() ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override public boolean isOutput() { return false; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testIsOutput() throws Exception { assertFalse( analyzer.isOutput() ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override public boolean isInput() { return true; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testIsInput() throws Exception { assertTrue( analyzer.isInput() ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override public Set<Class<? extends BaseStepMeta>> getSupportedSteps() { return new HashSet<Class<? extends BaseStepMeta>>() { { add( GetXMLDataMeta.class ); } }; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testGetSupportedSteps() { GetXMLDataStepAnalyzer analyzer = new GetXMLDataStepAnalyzer(); Set<Class<? extends BaseStepMeta>> types = analyzer.getSupportedSteps(); assertNotNull( types ); assertEquals( types.size(), 1 ); assertTrue( types.contains( GetXMLDataMeta.class ) ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override protected Set<StepField> getUsedFields( GetXMLDataMeta meta ) { Set<StepField> usedFields = new HashSet<>(); if ( meta.isInFields() ) { Set<StepField> stepFields = createStepFields( meta.getXMLField(), getInputs() ); usedFields.addAll( stepFields ); } return usedFields; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testGetUsedFields_xmlNotInField() throws Exception { when( meta.isInFields() ).thenReturn( false ); Set<StepField> usedFields = analyzer.getUsedFields( meta ); assertEquals( 0, usedFields.size() ); }
@Test public void testGetUsedFields() throws Exception { when( meta.isInFields() ).thenReturn( true ); when( meta.getXMLField() ).thenReturn( "xml" ); StepNodes inputs = new StepNodes(); inputs.addNode( "previousStep", "xml", node ); inputs.addNode( "previousStep", "otherField", node ); doReturn( inputs ).when( analyzer ).getInputs(); Set<StepField> usedFields = analyzer.getUsedFields( meta ); assertEquals( 1, usedFields.size() ); assertEquals( "xml", usedFields.iterator().next().getFieldName() ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override public IMetaverseNode createResourceNode( IExternalResourceInfo resource ) throws MetaverseException { return createFileNode( resource.getName(), descriptor ); } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testCreateResourceNode() throws Exception { IExternalResourceInfo res = mock( IExternalResourceInfo.class ); when( res.getName() ).thenReturn( "file: IMetaverseNode resourceNode = analyzer.createResourceNode( res ); assertNotNull( resourceNode ); assertEquals( DictionaryConst.NODE_TYPE_FILE, resourceNode.getType() ); } |
### Question:
GetXMLDataStepAnalyzer extends ExternalResourceStepAnalyzer<GetXMLDataMeta> { @Override protected void customAnalyze( GetXMLDataMeta meta, IMetaverseNode node ) throws MetaverseAnalyzerException { super.customAnalyze( meta, node ); node.setProperty( "loopXPath", meta.getLoopXPath() ); } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override Set<ComponentDerivationRecord> getChangeRecords( GetXMLDataMeta meta ); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); }### Answer:
@Test public void testCustomAnalyze() throws Exception { when( meta.getLoopXPath() ).thenReturn( "file/xpath/name" ); analyzer.customAnalyze( meta, node ); verify( node ).setProperty( "loopXPath", "file/xpath/name" ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override protected void customAnalyze( XMLOutputMeta meta, IMetaverseNode node ) throws MetaverseAnalyzerException { super.customAnalyze( meta, node ); node.setProperty( "parentnode", meta.getMainElement() ); node.setProperty( "rownode", meta.getRepeatElement() ); } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testCustomAnalyze() throws Exception { when( meta.getMainElement() ).thenReturn( "main" ); when( meta.getRepeatElement() ).thenReturn( "repeat" ); analyzer.customAnalyze( meta, node ); verify( node ).setProperty( "parentnode", "main" ); verify( node ).setProperty( "rownode", "repeat" ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override public Set<Class<? extends BaseStepMeta>> getSupportedSteps() { return new HashSet<Class<? extends BaseStepMeta>>() { { add( XMLOutputMeta.class ); } }; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testGetSupportedSteps() { XMLOutputStepAnalyzer analyzer = new XMLOutputStepAnalyzer(); Set<Class<? extends BaseStepMeta>> types = analyzer.getSupportedSteps(); assertNotNull( types ); assertEquals( types.size(), 1 ); assertTrue( types.contains( XMLOutputMeta.class ) ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override public Set<String> getOutputResourceFields( XMLOutputMeta meta ) { Set<String> fields = new HashSet<>(); XMLField[] outputFields = meta.getOutputFields(); for ( int i = 0; i < outputFields.length; i++ ) { XMLField outputField = outputFields[ i ]; fields.add( outputField.getFieldName() ); } return fields; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testGetOutputResourceFields() throws Exception { XMLField[] outputFields = new XMLField[2]; XMLField field1 = mock( XMLField.class ); XMLField field2 = mock( XMLField.class ); outputFields[0] = field1; outputFields[1] = field2; when( field1.getFieldName() ).thenReturn( "field1" ); when( field2.getFieldName() ).thenReturn( "field2" ); when( meta.getOutputFields() ).thenReturn( outputFields ); Set<String> outputResourceFields = analyzer.getOutputResourceFields( meta ); assertEquals( outputFields.length, outputResourceFields.size() ); for ( XMLField outputField : outputFields ) { assertTrue( outputResourceFields.contains( outputField.getFieldName() ) ); } } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override public IMetaverseNode createResourceNode( IExternalResourceInfo resource ) throws MetaverseException { return createFileNode( resource.getName(), getDescriptor() ); } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testCreateResourceNode() throws Exception { IExternalResourceInfo res = mock( IExternalResourceInfo.class ); when( res.getName() ).thenReturn( "file: IMetaverseNode resourceNode = analyzer.createResourceNode( res ); assertNotNull( resourceNode ); assertEquals( DictionaryConst.NODE_TYPE_FILE, resourceNode.getType() ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override public String getResourceInputNodeType() { return null; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testGetResourceInputNodeType() throws Exception { assertNull( analyzer.getResourceInputNodeType() ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override public String getResourceOutputNodeType() { return DictionaryConst.NODE_TYPE_FILE_FIELD; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testGetResourceOutputNodeType() throws Exception { assertEquals( DictionaryConst.NODE_TYPE_FILE_FIELD, analyzer.getResourceOutputNodeType() ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override public boolean isOutput() { return true; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testIsOutput() throws Exception { assertTrue( analyzer.isOutput() ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override public boolean isInput() { return false; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testIsInput() throws Exception { assertFalse( analyzer.isInput() ); } |
### Question:
XMLOutputStepAnalyzer extends ExternalResourceStepAnalyzer<XMLOutputMeta> { @Override protected Set<StepField> getUsedFields( XMLOutputMeta meta ) { return null; } @Override Set<Class<? extends BaseStepMeta>> getSupportedSteps(); @Override IMetaverseNode createResourceNode( IExternalResourceInfo resource ); @Override String getResourceInputNodeType(); @Override String getResourceOutputNodeType(); @Override boolean isOutput(); @Override boolean isInput(); @Override Set<String> getOutputResourceFields( XMLOutputMeta meta ); }### Answer:
@Test public void testGetUsedFields() throws Exception { assertNull( analyzer.getUsedFields( meta ) ); } |
### Question:
GoogleAnalyticsApiFacade { public static GoogleAnalyticsApiFacade createFor( String application, String oauthServiceAccount, String oauthKeyFile ) throws GeneralSecurityException, IOException, KettleFileException { return new GoogleAnalyticsApiFacade( GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), application, oauthServiceAccount, new File( KettleVFS.getFileObject( oauthKeyFile ).getURL().getPath() ) ); } GoogleAnalyticsApiFacade( HttpTransport httpTransport, JsonFactory jsonFactory, String application,
String oathServiceEmail, File keyFile ); static GoogleAnalyticsApiFacade createFor(
String application, String oauthServiceAccount, String oauthKeyFile ); void close(); Analytics getAnalytics(); }### Answer:
@Test public void exceptionIsThrowsForNonExistingFiles() throws Exception { GoogleAnalyticsApiFacade.createFor( "application-name", "account", path ); } |
### Question:
SalesforceUpdateMeta extends SalesforceStepMeta { public boolean supportsErrorHandling() { return true; } SalesforceUpdateMeta(); boolean isRollbackAllChangesOnError(); void setRollbackAllChangesOnError( boolean rollbackAllChangesOnError ); String[] getUpdateLookup(); void setUpdateLookup( String[] updateLookup ); Boolean[] getUseExternalId(); void setUseExternalId( Boolean[] useExternalId ); String[] getUpdateStream(); void setUpdateStream( String[] updateStream ); void setBatchSize( String value ); String getBatchSize(); int getBatchSizeInt(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); String getXML(); void allocate( int nrvalues ); void setDefault(); void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); }### Answer:
@Test public void testErrorHandling() { SalesforceStepMeta meta = new SalesforceUpdateMeta(); assertTrue( meta.supportsErrorHandling() ); } |
### Question:
SalesforceUpsertMeta extends SalesforceStepMeta { public boolean supportsErrorHandling() { return true; } SalesforceUpsertMeta(); boolean isRollbackAllChangesOnError(); void setRollbackAllChangesOnError( boolean rollbackAllChangesOnError ); String[] getUpdateLookup(); void setUpdateLookup( String[] updateLookup ); String[] getUpdateStream(); void setUpdateStream( String[] updateStream ); Boolean[] getUseExternalId(); void setUseExternalId( Boolean[] useExternalId ); void setUpsertField( String upsertField ); String getUpsertField(); void setBatchSize( String value ); String getBatchSize(); int getBatchSizeInt(); String getSalesforceIDFieldName(); void setSalesforceIDFieldName( String salesforceIDFieldName ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); String getXML(); void allocate( int nrvalues ); void setDefault(); void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); }### Answer:
@Test public void testErrorHandling() { SalesforceStepMeta meta = new SalesforceUpsertMeta(); assertTrue( meta.supportsErrorHandling() ); } |
### Question:
SalesforceDeleteMeta extends SalesforceStepMeta { public boolean supportsErrorHandling() { return true; } SalesforceDeleteMeta(); boolean isRollbackAllChangesOnError(); void setRollbackAllChangesOnError( boolean rollbackAllChangesOnError ); void setDeleteField( String DeleteField ); String getDeleteField(); void setBatchSize( String value ); String getBatchSize(); int getBatchSizeInt(); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); String getXML(); void setDefault(); void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); }### Answer:
@Test public void testErrorHandling() { SalesforceStepMeta meta = new SalesforceDeleteMeta(); assertTrue( meta.supportsErrorHandling() ); } |
### Question:
SalesforceInsertMeta extends SalesforceStepMeta { public boolean supportsErrorHandling() { return true; } SalesforceInsertMeta(); boolean isRollbackAllChangesOnError(); void setRollbackAllChangesOnError( boolean rollbackAllChangesOnError ); String[] getUpdateLookup(); void setUpdateLookup( String[] updateLookup ); String[] getUpdateStream(); void setUpdateStream( String[] updateStream ); Boolean[] getUseExternalId(); void setUseExternalId( Boolean[] useExternalId ); void setBatchSize( String value ); String getBatchSize(); int getBatchSizeInt(); String getSalesforceIDFieldName(); void setSalesforceIDFieldName( String salesforceIDFieldName ); void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ); Object clone(); String getXML(); void allocate( int nrvalues ); void setDefault(); void getFields( RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space, Repository repository, IMetaStore metaStore ); void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ); void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ); void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,
RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
Repository repository, IMetaStore metaStore ); StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr,
TransMeta transMeta, Trans trans ); StepDataInterface getStepData(); boolean supportsErrorHandling(); }### Answer:
@Test public void testErrorHandling() { SalesforceStepMeta meta = new SalesforceInsertMeta(); assertTrue( meta.supportsErrorHandling() ); } |
### Question:
SalesforceInputDialog extends SalesforceStepDialog { void addFields( String prefix, Set<String> fieldNames, XmlObject field ) { if ( isNullIdField( field ) ) { return; } String fieldname = prefix + field.getName().getLocalPart(); if ( field instanceof SObject ) { SObject sobject = (SObject) field; for ( XmlObject element : SalesforceConnection.getChildren( sobject ) ) { addFields( fieldname + ".", fieldNames, element ); } } else { addField( fieldname, fieldNames, (String) field.getValue() ); } } SalesforceInputDialog( Shell parent, Object in, TransMeta transMeta, String sname ); @Override String open(); void getData( SalesforceInputMeta in ); void setPosition(); }### Answer:
@Test public void testAddFieldsFromSOQLQuery() throws Exception { final Set<String> fields = new LinkedHashSet<>(); XmlObject testObject = createObject( "Field1", VALUE, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "No duplicates", new String[]{"Field1"}, fields.toArray() ); testObject = createObject( "Field2", VALUE, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "Two fields", new String[]{"Field1", "Field2"}, fields.toArray() ); }
@Test public void testAddFields_nullIdNotAdded() throws Exception { final Set<String> fields = new LinkedHashSet<>(); XmlObject testObject = createObject( "Id", null, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "Null Id field not added", new String[]{}, fields.toArray() ); }
@Test public void testAddFields_IdAdded() throws Exception { final Set<String> fields = new LinkedHashSet<>(); XmlObject testObject = createObject( "Id", VALUE, ObjectType.XMLOBJECT ); dialog.addFields( "", fields, testObject ); assertArrayEquals( "Id field added", new String[]{"Id"}, fields.toArray() ); } |
### Question:
RunConfigurationManager implements RunConfigurationService { public String[] getTypes() { List<String> types = new ArrayList<>(); for ( RunConfigurationProvider runConfigurationProvider : getRunConfigurationProviders() ) { types.add( runConfigurationProvider.getType() ); } return types.toArray( new String[ 0 ] ); } RunConfigurationManager( List<RunConfigurationProvider> runConfigurationProviders ); @Override List<RunConfiguration> load(); @Override RunConfiguration load( String name ); @Override boolean save( RunConfiguration runConfiguration ); @Override boolean delete( String name ); @Override void deleteAll(); String[] getTypes(); List<String> getNames(); List<String> getNames( String type ); RunConfiguration getRunConfigurationByType( String type ); RunConfigurationExecutor getExecutor( String type ); List<RunConfigurationProvider> getRunConfigurationProviders( String type ); List<RunConfigurationProvider> getRunConfigurationProviders(); RunConfigurationProvider getDefaultRunConfigurationProvider(); void setDefaultRunConfigurationProvider(
RunConfigurationProvider defaultRunConfigurationProvider ); }### Answer:
@Test public void testGetTypes() { String[] types = executionConfigurationManager.getTypes(); assertTrue( Arrays.asList( types ).contains( DefaultRunConfiguration.TYPE ) ); assertTrue( Arrays.asList( types ).contains( SparkRunConfiguration.TYPE ) ); } |
### Question:
RunConfigurationManager implements RunConfigurationService { @Override public List<RunConfiguration> load() { List<RunConfiguration> runConfigurations = new ArrayList<>(); for ( RunConfigurationProvider runConfigurationProvider : getRunConfigurationProviders() ) { runConfigurations.addAll( runConfigurationProvider.load() ); } Collections.sort( runConfigurations, ( o1, o2 ) -> { if ( o2.getName().equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { return 1; } return o1.getName().compareToIgnoreCase( o2.getName() ); } ); return runConfigurations; } RunConfigurationManager( List<RunConfigurationProvider> runConfigurationProviders ); @Override List<RunConfiguration> load(); @Override RunConfiguration load( String name ); @Override boolean save( RunConfiguration runConfiguration ); @Override boolean delete( String name ); @Override void deleteAll(); String[] getTypes(); List<String> getNames(); List<String> getNames( String type ); RunConfiguration getRunConfigurationByType( String type ); RunConfigurationExecutor getExecutor( String type ); List<RunConfigurationProvider> getRunConfigurationProviders( String type ); List<RunConfigurationProvider> getRunConfigurationProviders(); RunConfigurationProvider getDefaultRunConfigurationProvider(); void setDefaultRunConfigurationProvider(
RunConfigurationProvider defaultRunConfigurationProvider ); }### Answer:
@Test public void testLoad() { List<RunConfiguration> runConfigurations = executionConfigurationManager.load(); assertEquals( runConfigurations.size(), 3 ); }
@Test public void testLoadByName() { DefaultRunConfiguration defaultRunConfiguration = (DefaultRunConfiguration) executionConfigurationManager .load( "Default Configuration" ); assertNotNull( defaultRunConfiguration ); assertEquals( defaultRunConfiguration.getName(), "Default Configuration" ); } |
### Question:
RunConfigurationManager implements RunConfigurationService { public List<String> getNames() { List<String> names = new ArrayList<>(); for ( RunConfigurationProvider runConfigurationProvider : getRunConfigurationProviders() ) { names.addAll( runConfigurationProvider.getNames() ); } Collections.sort( names, ( o1, o2 ) -> { if ( o2.equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { return 1; } return o1.compareToIgnoreCase( o2 ); } ); return names; } RunConfigurationManager( List<RunConfigurationProvider> runConfigurationProviders ); @Override List<RunConfiguration> load(); @Override RunConfiguration load( String name ); @Override boolean save( RunConfiguration runConfiguration ); @Override boolean delete( String name ); @Override void deleteAll(); String[] getTypes(); List<String> getNames(); List<String> getNames( String type ); RunConfiguration getRunConfigurationByType( String type ); RunConfigurationExecutor getExecutor( String type ); List<RunConfigurationProvider> getRunConfigurationProviders( String type ); List<RunConfigurationProvider> getRunConfigurationProviders(); RunConfigurationProvider getDefaultRunConfigurationProvider(); void setDefaultRunConfigurationProvider(
RunConfigurationProvider defaultRunConfigurationProvider ); }### Answer:
@Test public void testGetNames() { List<String> names = executionConfigurationManager.getNames(); assertTrue( names.contains( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ); assertTrue( names.contains( "Default Configuration" ) ); assertTrue( names.contains( "Spark Configuration" ) ); } |
### Question:
RunConfigurationManager implements RunConfigurationService { public RunConfiguration getRunConfigurationByType( String type ) { RunConfigurationProvider runConfigurationProvider = getProvider( type ); if ( runConfigurationProvider != null ) { return runConfigurationProvider.getConfiguration(); } return null; } RunConfigurationManager( List<RunConfigurationProvider> runConfigurationProviders ); @Override List<RunConfiguration> load(); @Override RunConfiguration load( String name ); @Override boolean save( RunConfiguration runConfiguration ); @Override boolean delete( String name ); @Override void deleteAll(); String[] getTypes(); List<String> getNames(); List<String> getNames( String type ); RunConfiguration getRunConfigurationByType( String type ); RunConfigurationExecutor getExecutor( String type ); List<RunConfigurationProvider> getRunConfigurationProviders( String type ); List<RunConfigurationProvider> getRunConfigurationProviders(); RunConfigurationProvider getDefaultRunConfigurationProvider(); void setDefaultRunConfigurationProvider(
RunConfigurationProvider defaultRunConfigurationProvider ); }### Answer:
@Test public void testGetRunConfigurationByType() { DefaultRunConfiguration defaultRunConfiguration = (DefaultRunConfiguration) executionConfigurationManager.getRunConfigurationByType( DefaultRunConfiguration.TYPE ); SparkRunConfiguration sparkRunConfiguration = (SparkRunConfiguration) executionConfigurationManager.getRunConfigurationByType( SparkRunConfiguration.TYPE ); assertNotNull( defaultRunConfiguration ); assertNotNull( sparkRunConfiguration ); } |
### Question:
RunConfigurationManager implements RunConfigurationService { public RunConfigurationExecutor getExecutor( String type ) { RunConfigurationProvider runConfigurationProvider = getProvider( type ); if ( runConfigurationProvider != null ) { return runConfigurationProvider.getExecutor(); } return null; } RunConfigurationManager( List<RunConfigurationProvider> runConfigurationProviders ); @Override List<RunConfiguration> load(); @Override RunConfiguration load( String name ); @Override boolean save( RunConfiguration runConfiguration ); @Override boolean delete( String name ); @Override void deleteAll(); String[] getTypes(); List<String> getNames(); List<String> getNames( String type ); RunConfiguration getRunConfigurationByType( String type ); RunConfigurationExecutor getExecutor( String type ); List<RunConfigurationProvider> getRunConfigurationProviders( String type ); List<RunConfigurationProvider> getRunConfigurationProviders(); RunConfigurationProvider getDefaultRunConfigurationProvider(); void setDefaultRunConfigurationProvider(
RunConfigurationProvider defaultRunConfigurationProvider ); }### Answer:
@Test public void testGetExecutor() { DefaultRunConfigurationExecutor defaultRunConfigurationExecutor = (DefaultRunConfigurationExecutor) executionConfigurationManager.getExecutor( DefaultRunConfiguration.TYPE ); assertNotNull( defaultRunConfigurationExecutor ); } |
### Question:
RunConfigurationRunExtensionPoint implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException { ExecutionConfiguration executionConfiguration = (ExecutionConfiguration) ( (Object[]) o )[ 0 ]; AbstractMeta meta = (AbstractMeta) ( (Object[]) o )[ 1 ]; VariableSpace variableSpace = (VariableSpace) ( (Object[]) o )[ 2 ]; EmbeddedMetaStore embeddedMetaStore = meta.getEmbeddedMetaStore(); RunConfiguration runConfiguration = runConfigurationManager.load( executionConfiguration.getRunConfiguration() ); if ( runConfiguration == null ) { RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build( embeddedMetaStore ); runConfiguration = embeddedRunConfigurationManager.load( executionConfiguration.getRunConfiguration() ); } if ( runConfiguration != null ) { RunConfigurationExecutor runConfigurationExecutor = runConfigurationManager.getExecutor( runConfiguration.getType() ); if ( runConfigurationExecutor != null ) { runConfigurationExecutor.execute( runConfiguration, executionConfiguration, meta, variableSpace ); } } else { String name = ""; if ( variableSpace instanceof TransMeta ) { name = ( (TransMeta) variableSpace ).getFilename(); } throw new KettleException( BaseMessages .getString( PKG, "RunConfigurationRunExtensionPoint.ConfigNotFound.Error", name, executionConfiguration.getRunConfiguration(), "{0}" ) ); } } RunConfigurationRunExtensionPoint( RunConfigurationManager runConfigurationManager ); @Override void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ); }### Answer:
@Test public void testCallExtensionPoint() throws Exception { runConfigurationRunExtensionPoint.callExtensionPoint( log, new Object[] { transExecutionConfiguration, abstractMeta, variableSpace } ); verify( runConfigurationExecutor ) .execute( runConfiguration, transExecutionConfiguration, abstractMeta, variableSpace ); }
@Test public void testCallExtensionPointEmbedded() throws Exception { when( runConfigurationManager.load( "RUN_CONF" ) ).thenReturn( null ); try { runConfigurationRunExtensionPoint.callExtensionPoint( log, new Object[] { transExecutionConfiguration, abstractMeta, variableSpace } ); fail(); } catch ( Exception e ) { } } |
### Question:
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException { AbstractMeta abstractMeta = (AbstractMeta) o; final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore(); RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build( embeddedMetaStore ); List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load(); for ( RunConfiguration runConfiguration : runConfigurationList ) { if ( !runConfiguration.getName().equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { runConfigurationManager.save( runConfiguration ); } } } RunConfigurationImportExtensionPoint( RunConfigurationManager runConfigurationManager ); @Override void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ); }### Answer:
@Test public void testCallExtensionPoint() throws Exception { runConfigurationImportExtensionPoint.callExtensionPoint( log, abstractMeta ); verify( abstractMeta ).getEmbeddedMetaStore(); } |
### Question:
KettleDatabaseRepositoryCreationHelper { protected int getRepoStringLength() { return database.getDatabaseMeta().getDatabaseInterface().getMaxVARCHARLength() - 1 > 0 ? database.getDatabaseMeta() .getDatabaseInterface().getMaxVARCHARLength() - 1 : KettleDatabaseRepository.REP_ORACLE_STRING_LENGTH; } KettleDatabaseRepositoryCreationHelper( KettleDatabaseRepository repository ); synchronized void createRepositorySchema( ProgressMonitorListener monitor, boolean upgrade,
List<String> statements, boolean dryrun ); List<String> updateStepTypes( List<String> statements, boolean dryrun, boolean create ); List<String> updateDatabaseTypes( List<String> statements, boolean dryrun, boolean create ); void updateJobEntryTypes( List<String> statements, boolean dryrun, boolean create ); }### Answer:
@Test public void testOracleDBRepoStringLength() throws Exception { KettleEnvironment.init(); DatabaseMeta databaseMeta = new DatabaseMeta( "OraRepo", "ORACLE", "JDBC", null, "test", null, null, null ); repositoryMeta = new KettleDatabaseRepositoryMeta( "KettleDatabaseRepository", "OraRepo", "Ora Repository", databaseMeta ); repository = new KettleDatabaseRepository(); repository.init( repositoryMeta ); KettleDatabaseRepositoryCreationHelper helper = new KettleDatabaseRepositoryCreationHelper( repository ); int repoStringLength = helper.getRepoStringLength(); assertEquals( EXPECTED_ORACLE_DB_REPO_STRING, repoStringLength ); }
@Test public void testDefaultDBRepoStringLength() throws Exception { KettleEnvironment.init(); DatabaseMeta databaseMeta = new DatabaseMeta(); databaseMeta.setDatabaseInterface( new TestDatabaseMeta() ); repositoryMeta = new KettleDatabaseRepositoryMeta( "KettleDatabaseRepository", "TestRepo", "Test Repository", databaseMeta ); repository = new KettleDatabaseRepository(); repository.init( repositoryMeta ); KettleDatabaseRepositoryCreationHelper helper = new KettleDatabaseRepositoryCreationHelper( repository ); int repoStringLength = helper.getRepoStringLength(); assertEquals( EXPECTED_DEFAULT_DB_REPO_STRING, repoStringLength ); } |
### Question:
PurRepositoryConnector implements IRepositoryConnector { @Override public synchronized void disconnect() { if ( serviceManager != null ) { serviceManager.close(); } serviceManager = null; } PurRepositoryConnector( PurRepository purRepository, PurRepositoryMeta repositoryMeta, RootRef rootRef ); synchronized RepositoryConnectResult connect( final String username, final String password ); @Override synchronized void disconnect(); LogChannelInterface getLog(); @Override ServiceManager getServiceManager(); static boolean inProcess(); }### Answer:
@Test public void testPDI12439PurRepositoryConnectorDoesntNPEAfterMultipleDisconnects() { PurRepository mockPurRepository = mock( PurRepository.class ); PurRepositoryMeta mockPurRepositoryMeta = mock( PurRepositoryMeta.class ); RootRef mockRootRef = mock( RootRef.class ); PurRepositoryConnector purRepositoryConnector = new PurRepositoryConnector( mockPurRepository, mockPurRepositoryMeta, mockRootRef ); purRepositoryConnector.disconnect(); purRepositoryConnector.disconnect(); } |
### Question:
DatabaseDelegate extends AbstractDelegate implements ITransformer, SharedObjectAssembler<DatabaseMeta>,
java.io.Serializable { public RepositoryElementInterface dataNodeToElement( final DataNode rootNode ) throws KettleException { DatabaseMeta databaseMeta = new DatabaseMeta(); dataNodeToElement( rootNode, databaseMeta ); return databaseMeta; } DatabaseDelegate( final PurRepository repo ); DataNode elementToDataNode( final RepositoryElementInterface element ); RepositoryElementInterface dataNodeToElement( final DataNode rootNode ); void dataNodeToElement( final DataNode rootNode, final RepositoryElementInterface element ); Repository getRepository(); DatabaseMeta assemble( RepositoryFile file, NodeRepositoryFileData data, VersionSummary version ); }### Answer:
@Test public void testExtraOptionUnescapeWithInvalidCharInDatabaseType() throws KettleException { DataNode mockDataNode = mock( DataNode.class ); DataNode unescapedExtraOptions = new DataNode( "options" ); unescapedExtraOptions.setProperty( "EXTRA_OPTION_AS%2F400.optionExtraOption", true ); when( mockDataNode.getNode( "attributes" ) ).thenReturn( unescapedExtraOptions ); DatabaseMeta unescapedDbMeta = mock( DatabaseMeta.class ); when( unescapedDbMeta.getAttributes() ).thenReturn( new Properties() ); dbDelegate.dataNodeToElement( mockDataNode, unescapedDbMeta ); assertEquals( "true", unescapedDbMeta.getAttributes().getProperty( "EXTRA_OPTION_AS/400.optionExtraOption" ) ); } |
### Question:
PurRepositoryMeta extends BaseRepositoryMeta implements RepositoryMeta, java.io.Serializable { @Override public void populate( Map<String, Object> properties, RepositoriesMeta repositoriesMeta ) { super.populate( properties, repositoriesMeta ); String url = (String) properties.get( URL ); PurRepositoryLocation purRepositoryLocation = new PurRepositoryLocation( url ); setRepositoryLocation( purRepositoryLocation ); } PurRepositoryMeta(); PurRepositoryMeta( String id, String name, String description, PurRepositoryLocation repositoryLocation,
boolean versionCommentMandatory ); String getXML(); void loadXML( Node repnode, List<DatabaseMeta> databases ); RepositoryCapabilities getRepositoryCapabilities(); PurRepositoryLocation getRepositoryLocation(); void setRepositoryLocation( PurRepositoryLocation repositoryLocation ); boolean isVersionCommentMandatory(); void setVersionCommentMandatory( boolean versionCommentMandatory ); RepositoryMeta clone(); @Override void populate( Map<String, Object> properties, RepositoriesMeta repositoriesMeta ); @SuppressWarnings( "unchecked" ) @Override JSONObject toJSONObject(); static final String URL; static String REPOSITORY_TYPE_ID; }### Answer:
@Test public void testPopulate() throws Exception { Map<String, Object> properties = new HashMap<String, Object>(); properties.put( "displayName", "Display Name" ); properties.put( "url", "URL" ); properties.put( "description", "Description" ); properties.put( "isDefault", true ); PurRepositoryMeta purRepositoryMeta = new PurRepositoryMeta(); purRepositoryMeta.populate( properties, repositoriesMeta ); assertEquals( "Display Name", purRepositoryMeta.getName() ); assertEquals( "URL", purRepositoryMeta.getRepositoryLocation().getUrl() ); assertEquals( "Description", purRepositoryMeta.getDescription() ); assertEquals( true, purRepositoryMeta.isDefault() ); } |
### Question:
UIEEJob extends UIJob implements ILockObject, IRevisionObject, IAclObject, java.io.Serializable { @Override public String getImage() { if ( isLocked() ) { return "ui/images/lock.svg"; } return "ui/images/jobrepo.svg"; } UIEEJob( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testGetImage() { String image = uiJob.getImage(); assertNotNull( image ); File f = new File( image ); when( mockEERepositoryObject.getLock() ).thenReturn( mockRepositoryLock ); String image2 = uiJob.getImage(); assertNotNull( image2 ); f = new File( image2 ); assertNotEquals( image, image2 ); } |
### Question:
UIEEJob extends UIJob implements ILockObject, IRevisionObject, IAclObject, java.io.Serializable { public String getLockMessage() throws KettleException { return repObj.getLockMessage(); } UIEEJob( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testGetLockMessage() throws Exception { when( mockEERepositoryObject.getLockMessage() ).thenReturn( LOCK_MESSAGE ); assertEquals( LOCK_MESSAGE, uiJob.getLockMessage() ); } |
### Question:
UIEEJob extends UIJob implements ILockObject, IRevisionObject, IAclObject, java.io.Serializable { public void lock( String lockNote ) throws KettleException { RepositoryLock lock = lockService.lockJob( getObjectId(), lockNote ); repObj.setLock( lock ); uiParent.fireCollectionChanged(); } UIEEJob( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testLock() throws Exception { when( mockLockService.lockJob( mockObjectId, LOCK_NOTE ) ).thenReturn( mockRepositoryLock ); uiJob.lock( LOCK_NOTE ); verify( mockEERepositoryObject ).setLock( mockRepositoryLock ); verify( mockParent ).fireCollectionChanged(); uiJob.unlock(); verify( mockEERepositoryObject ).setLock( null ); verify( mockParent, times( 2 ) ).fireCollectionChanged(); } |
### Question:
UIEEJob extends UIJob implements ILockObject, IRevisionObject, IAclObject, java.io.Serializable { @Override public boolean hasAccess( RepositoryFilePermission perm ) throws KettleException { if ( hasAccess == null ) { hasAccess = new HashMap<RepositoryFilePermission, Boolean>(); } if ( hasAccess.get( perm ) == null ) { hasAccess.put( perm, new Boolean( aclService.hasAccess( repObj.getObjectId(), perm ) ) ); } return hasAccess.get( perm ).booleanValue(); } UIEEJob( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testAccess() throws Exception { when( mockAclService.hasAccess( mockObjectId, RepositoryFilePermission.READ ) ).thenReturn( true ); when( mockAclService.hasAccess( mockObjectId, RepositoryFilePermission.WRITE ) ).thenReturn( false ); assertTrue( uiJob.hasAccess( RepositoryFilePermission.READ ) ); assertFalse( uiJob.hasAccess( RepositoryFilePermission.WRITE ) ); } |
### Question:
UIRepositoryObjectAcl extends XulEventSourceAdapter implements java.io.Serializable { public EnumSet<RepositoryFilePermission> getPermissionSet() { return ace.getPermissions(); } UIRepositoryObjectAcl( ObjectAce ace ); @Override boolean equals( Object obj ); ObjectAce getAce(); String getRecipientName(); void setRecipientName( String recipientName ); ObjectRecipient.Type getRecipientType(); void setRecipientType( ObjectRecipient.Type recipientType ); EnumSet<RepositoryFilePermission> getPermissionSet(); void setPermissionSet( RepositoryFilePermission first, RepositoryFilePermission... rest ); void setPermissionSet( EnumSet<RepositoryFilePermission> permissionSet ); void addPermission( RepositoryFilePermission permissionToAdd ); void removePermission( RepositoryFilePermission permissionToRemove ); @Override String toString(); }### Answer:
@Test public void testGetPermissionSet() { UIRepositoryObjectAcl uiAcl = new UIRepositoryObjectAcl( createObjectAce() ); EnumSet<RepositoryFilePermission> permissions = uiAcl.getPermissionSet(); assertNotNull( permissions ); assertEquals( 1, permissions.size() ); assertTrue( permissions.contains( RepositoryFilePermission.ALL ) ); } |
### Question:
UIRepositoryObjectAcl extends XulEventSourceAdapter implements java.io.Serializable { @Override public String toString() { return ace.getRecipient().toString(); } UIRepositoryObjectAcl( ObjectAce ace ); @Override boolean equals( Object obj ); ObjectAce getAce(); String getRecipientName(); void setRecipientName( String recipientName ); ObjectRecipient.Type getRecipientType(); void setRecipientType( ObjectRecipient.Type recipientType ); EnumSet<RepositoryFilePermission> getPermissionSet(); void setPermissionSet( RepositoryFilePermission first, RepositoryFilePermission... rest ); void setPermissionSet( EnumSet<RepositoryFilePermission> permissionSet ); void addPermission( RepositoryFilePermission permissionToAdd ); void removePermission( RepositoryFilePermission permissionToRemove ); @Override String toString(); }### Answer:
@Test public void testToString() { UIRepositoryObjectAcl uiAcl = new UIRepositoryObjectAcl( createObjectAce() ); String s = uiAcl.toString(); assertNotNull( s ); assertTrue( s.contains( RECIPIENT1 ) ); } |
### Question:
UIEETransformation extends UITransformation implements ILockObject, IRevisionObject, IAclObject,
java.io.Serializable { @Override public String getImage() { try { if ( isLocked() ) { return "ui/images/lock.svg"; } } catch ( KettleException e ) { throw new RuntimeException( e ); } return "ui/images/transrepo.svg"; } UIEETransformation( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testGetImage() { String image = uiTransformation.getImage(); assertNotNull( image ); File f = new File( image ); when( mockEERepositoryObject.isLocked() ).thenReturn( true ); String image2 = uiTransformation.getImage(); assertNotNull( image2 ); f = new File( image2 ); assertNotEquals( image, image2 ); } |
### Question:
UIEETransformation extends UITransformation implements ILockObject, IRevisionObject, IAclObject,
java.io.Serializable { public String getLockMessage() throws KettleException { return repObj.getLockMessage(); } UIEETransformation( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testGetLockMessage() throws Exception { when( mockEERepositoryObject.getLockMessage() ).thenReturn( LOCK_MESSAGE ); assertEquals( LOCK_MESSAGE, uiTransformation.getLockMessage() ); } |
### Question:
UIEETransformation extends UITransformation implements ILockObject, IRevisionObject, IAclObject,
java.io.Serializable { public void lock( String lockNote ) throws KettleException { RepositoryLock lock = lockService.lockTransformation( getObjectId(), lockNote ); repObj.setLock( lock ); uiParent.fireCollectionChanged(); } UIEETransformation( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testLock() throws Exception { when( mockLockService.lockTransformation( mockObjectId, LOCK_NOTE ) ).thenReturn( mockRepositoryLock ); uiTransformation.lock( LOCK_NOTE ); verify( mockEERepositoryObject ).setLock( mockRepositoryLock ); verify( mockParent ).fireCollectionChanged(); uiTransformation.unlock(); verify( mockEERepositoryObject ).setLock( null ); verify( mockParent, times( 2 ) ).fireCollectionChanged(); } |
### Question:
UIEETransformation extends UITransformation implements ILockObject, IRevisionObject, IAclObject,
java.io.Serializable { @Override public boolean hasAccess( RepositoryFilePermission perm ) throws KettleException { if ( hasAccess == null ) { hasAccess = new HashMap<RepositoryFilePermission, Boolean>(); } if ( hasAccess.get( perm ) == null ) { hasAccess.put( perm, new Boolean( aclService.hasAccess( getObjectId(), perm ) ) ); } return hasAccess.get( perm ).booleanValue(); } UIEETransformation( RepositoryElementMetaInterface rc, UIRepositoryDirectory parent, Repository rep ); @Override String getImage(); String getLockMessage(); void lock( String lockNote ); void unlock(); boolean isLocked(); RepositoryLock getRepositoryLock(); UIRepositoryObjectRevisions getRevisions(); void restoreRevision( UIRepositoryObjectRevision revision, String commitMessage ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); @Override Boolean getVersioningEnabled(); @Override Boolean getVersionCommentEnabled(); }### Answer:
@Test public void testAccess() throws Exception { when( mockAclService.hasAccess( mockObjectId, RepositoryFilePermission.READ ) ).thenReturn( true ); when( mockAclService.hasAccess( mockObjectId, RepositoryFilePermission.WRITE ) ).thenReturn( false ); assertTrue( uiTransformation.hasAccess( RepositoryFilePermission.READ ) ); assertFalse( uiTransformation.hasAccess( RepositoryFilePermission.WRITE ) ); } |
### Question:
UIRepositoryObjectAcls extends XulEventSourceAdapter implements java.io.Serializable { public void setObjectAcl( ObjectAcl obj ) { this.obj = obj; this.firePropertyChange( "acls", null, getAcls() ); this.firePropertyChange( "entriesInheriting", null, isEntriesInheriting() ); } UIRepositoryObjectAcls(); void setObjectAcl( ObjectAcl obj ); ObjectAcl getObjectAcl(); List<UIRepositoryObjectAcl> getAcls(); void setAcls( List<UIRepositoryObjectAcl> acls ); void addAcls( List<UIRepositoryObjectAcl> aclsToAdd ); void addDefaultAcls( List<UIRepositoryObjectAcl> aclsToAdd ); void addAcl( UIRepositoryObjectAcl aclToAdd ); void addDefaultAcl( UIRepositoryObjectAcl aclToAdd ); void removeAcls( List<UIRepositoryObjectAcl> aclsToRemove ); void removeAcl( String recipientName ); void removeSelectedAcls(); void updateAcl( UIRepositoryObjectAcl aclToUpdate ); UIRepositoryObjectAcl getAcl( String recipient ); List<UIRepositoryObjectAcl> getSelectedAclList(); void setSelectedAclList( List<UIRepositoryObjectAcl> list ); boolean isEntriesInheriting(); void setEntriesInheriting( boolean entriesInheriting ); ObjectRecipient getOwner(); void setRemoveEnabled( boolean removeEnabled ); boolean isRemoveEnabled(); int getAceIndex( ObjectAce ace ); ObjectAce getAceAtIndex( int index ); void setModelDirty( boolean modelDirty ); boolean isModelDirty(); boolean hasManageAclAccess(); void setHasManageAclAccess( boolean hasManageAclAccess ); void clear(); }### Answer:
@Test public void testSetObjectAcl() { ObjectAcl objectAcl = repositoryObjectAcls.getObjectAcl(); assertEquals( repObjectAcl, objectAcl ); } |
### Question:
UIRepositoryObjectAcls extends XulEventSourceAdapter implements java.io.Serializable { public ObjectRecipient getOwner() { if ( obj != null ) { return obj.getOwner(); } else { return null; } } UIRepositoryObjectAcls(); void setObjectAcl( ObjectAcl obj ); ObjectAcl getObjectAcl(); List<UIRepositoryObjectAcl> getAcls(); void setAcls( List<UIRepositoryObjectAcl> acls ); void addAcls( List<UIRepositoryObjectAcl> aclsToAdd ); void addDefaultAcls( List<UIRepositoryObjectAcl> aclsToAdd ); void addAcl( UIRepositoryObjectAcl aclToAdd ); void addDefaultAcl( UIRepositoryObjectAcl aclToAdd ); void removeAcls( List<UIRepositoryObjectAcl> aclsToRemove ); void removeAcl( String recipientName ); void removeSelectedAcls(); void updateAcl( UIRepositoryObjectAcl aclToUpdate ); UIRepositoryObjectAcl getAcl( String recipient ); List<UIRepositoryObjectAcl> getSelectedAclList(); void setSelectedAclList( List<UIRepositoryObjectAcl> list ); boolean isEntriesInheriting(); void setEntriesInheriting( boolean entriesInheriting ); ObjectRecipient getOwner(); void setRemoveEnabled( boolean removeEnabled ); boolean isRemoveEnabled(); int getAceIndex( ObjectAce ace ); ObjectAce getAceAtIndex( int index ); void setModelDirty( boolean modelDirty ); boolean isModelDirty(); boolean hasManageAclAccess(); void setHasManageAclAccess( boolean hasManageAclAccess ); void clear(); }### Answer:
@Test public void testGetOwner() { assertEquals( RECIPIENT0, repositoryObjectAcls.getOwner().getName() ); repositoryObjectAcls = new UIRepositoryObjectAcls(); assertNull( repositoryObjectAcls.getOwner() ); } |
### Question:
UIEERepositoryDirectory extends UIRepositoryDirectory implements IAclObject, java.io.Serializable { public void setName( String name, boolean renameHomeDirectories ) throws Exception { if ( getDirectory().getName().equalsIgnoreCase( name ) ) { return; } if ( rep instanceof RepositoryExtended ) { ( (RepositoryExtended) rep ).renameRepositoryDirectory( getDirectory().getObjectId(), null, name, renameHomeDirectories ); } else { rep.renameRepositoryDirectory( getDirectory().getObjectId(), null, name ); } obj = rep.getObjectInformation( getObjectId(), getRepositoryElementType() ); refresh(); } UIEERepositoryDirectory(); UIEERepositoryDirectory( RepositoryDirectoryInterface rd, UIRepositoryDirectory uiParent, Repository rep ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); void delete( boolean deleteHomeDirectories ); void setName( String name, boolean renameHomeDirectories ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); }### Answer:
@Test public void testSetName() throws Exception { final String newDirName = "foo"; when( mockRepositoryDirectory.getName() ).thenReturn( "dirName" ); uiRepDir.setName( newDirName, true ); verify( mockRepository ).renameRepositoryDirectory( mockRepositoryDirectory.getObjectId(), null, newDirName ); uiPurRepDir.setName( newDirName, true ); verify( mockPurRepository ).renameRepositoryDirectory( mockRepositoryDirectory.getObjectId(), null, newDirName, true ); } |
### Question:
UIEERepositoryDirectory extends UIRepositoryDirectory implements IAclObject, java.io.Serializable { @Override public boolean hasAccess( RepositoryFilePermission perm ) throws KettleException { if ( hasAccess == null ) { hasAccess = new HashMap<RepositoryFilePermission, Boolean>(); } if ( hasAccess.get( perm ) == null ) { hasAccess.put( perm, new Boolean( aclService.hasAccess( getObjectId(), perm ) ) ); } return hasAccess.get( perm ).booleanValue(); } UIEERepositoryDirectory(); UIEERepositoryDirectory( RepositoryDirectoryInterface rd, UIRepositoryDirectory uiParent, Repository rep ); void getAcls( UIRepositoryObjectAcls acls, boolean forceParentInheriting ); void getAcls( UIRepositoryObjectAcls acls ); void setAcls( UIRepositoryObjectAcls security ); void delete( boolean deleteHomeDirectories ); void setName( String name, boolean renameHomeDirectories ); @Override void clearAcl(); @Override boolean hasAccess( RepositoryFilePermission perm ); }### Answer:
@Test public void testAccess() throws Exception { when( mockAclService.hasAccess( mockObjectId, RepositoryFilePermission.READ ) ).thenReturn( true ); when( mockAclService.hasAccess( mockObjectId, RepositoryFilePermission.WRITE ) ).thenReturn( false ); assertTrue( uiPurRepDir.hasAccess( RepositoryFilePermission.READ ) ); assertFalse( uiPurRepDir.hasAccess( RepositoryFilePermission.WRITE ) ); } |
### Question:
PermissionsCheckboxHandler { public void setAllChecked( boolean value ) { for ( PermissionsCheckboxes permissionsCheckboxes : ALL_PERMISSIONS ) { permissionsCheckboxes.permissionCheckbox.setChecked( value ); } } PermissionsCheckboxHandler( XulCheckbox readCheckbox, XulCheckbox writeCheckbox, XulCheckbox deleteCheckbox,
XulCheckbox manageCheckbox ); EnumSet<RepositoryFilePermission> processCheckboxes(); EnumSet<RepositoryFilePermission> processCheckboxes( boolean enableAppropriate ); void updateCheckboxes( EnumSet<RepositoryFilePermission> permissionEnumSet ); void updateCheckboxes( boolean enableAppropriate, EnumSet<RepositoryFilePermission> permissionEnumSet ); void setAllChecked( boolean value ); void setAllDisabled( boolean value ); }### Answer:
@Test public void testSetAllUncheckedUnchecksAll() { boolean checked = false; permissionsCheckboxHandler.setAllChecked( checked ); verify( readCheckbox, times( 1 ) ).setChecked( checked ); verify( writeCheckbox, times( 1 ) ).setChecked( checked ); verify( deleteCheckbox, times( 1 ) ).setChecked( checked ); verify( manageCheckbox, times( 1 ) ).setChecked( checked ); }
@Test public void testSetAllCheckedChecksAll() { boolean checked = true; permissionsCheckboxHandler.setAllChecked( checked ); verify( readCheckbox, times( 1 ) ).setChecked( checked ); verify( writeCheckbox, times( 1 ) ).setChecked( checked ); verify( deleteCheckbox, times( 1 ) ).setChecked( checked ); verify( manageCheckbox, times( 1 ) ).setChecked( checked ); } |
### Question:
RepositoriesMeta { public String toString() { return getClass().getSimpleName(); } RepositoriesMeta(); void clear(); void addDatabase( DatabaseMeta ci ); void addRepository( RepositoryMeta ri ); void addDatabase( int p, DatabaseMeta ci ); void addRepository( int p, RepositoryMeta ri ); DatabaseMeta getDatabase( int i ); RepositoryMeta getRepository( int i ); void removeDatabase( int i ); void removeRepository( int i ); int nrDatabases(); int nrRepositories(); DatabaseMeta searchDatabase( String name ); RepositoryMeta searchRepository( String name ); int indexOfDatabase( DatabaseMeta di ); int indexOfRepository( RepositoryMeta ri ); RepositoryMeta findRepository( String name ); RepositoryMeta findRepositoryById( String id ); boolean readData(); void readDataFromInputStream( InputStream is ); String getXML(); void writeData(); String toString(); RepositoriesMeta clone(); String getErrorMessage(); LogChannelInterface getLog(); }### Answer:
@Test public void testToString() throws Exception { RepositoriesMeta repositoriesMeta = new RepositoriesMeta(); assertEquals( "RepositoriesMeta", repositoriesMeta.toString() ); } |
### Question:
PermissionsCheckboxHandler { public void setAllDisabled( boolean value ) { for ( PermissionsCheckboxes permissionsCheckboxes : ALL_PERMISSIONS ) { permissionsCheckboxes.permissionCheckbox.setDisabled( value ); } } PermissionsCheckboxHandler( XulCheckbox readCheckbox, XulCheckbox writeCheckbox, XulCheckbox deleteCheckbox,
XulCheckbox manageCheckbox ); EnumSet<RepositoryFilePermission> processCheckboxes(); EnumSet<RepositoryFilePermission> processCheckboxes( boolean enableAppropriate ); void updateCheckboxes( EnumSet<RepositoryFilePermission> permissionEnumSet ); void updateCheckboxes( boolean enableAppropriate, EnumSet<RepositoryFilePermission> permissionEnumSet ); void setAllChecked( boolean value ); void setAllDisabled( boolean value ); }### Answer:
@Test public void testSetAllDisabledDisablesAll() { boolean disabled = true; permissionsCheckboxHandler.setAllDisabled( disabled ); verify( readCheckbox, times( 1 ) ).setDisabled( disabled ); verify( writeCheckbox, times( 1 ) ).setDisabled( disabled ); verify( deleteCheckbox, times( 1 ) ).setDisabled( disabled ); verify( manageCheckbox, times( 1 ) ).setDisabled( disabled ); }
@Test public void testSetAllEnabledEnablesAll() { boolean disabled = false; permissionsCheckboxHandler.setAllDisabled( disabled ); verify( readCheckbox, times( 1 ) ).setDisabled( disabled ); verify( writeCheckbox, times( 1 ) ).setDisabled( disabled ); verify( deleteCheckbox, times( 1 ) ).setDisabled( disabled ); verify( manageCheckbox, times( 1 ) ).setDisabled( disabled ); } |
### Question:
DataHandler extends AbstractXulEventHandler { public void editOptions( int index ) { if ( index + 1 == optionsParameterTree.getRows() ) { Object[][] values = optionsParameterTree.getValues(); Object[] row = values[values.length - 1]; if ( row != null && ( !StringUtils.isEmpty( (String) row[0] ) || !StringUtils.isEmpty( (String) row[1] ) ) ) { XulTreeRow newRow = optionsParameterTree.getRootChildren().addNewRow(); newRow.addCellText( 0, "" ); newRow.addCellText( 1, "" ); } } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }### Answer:
@Test public void testEditOptions() throws Exception { } |
### Question:
PDIImportUtil { public static Repository connectToRepository( String repositoryName ) throws KettleException { return repositoryFactory.connect( repositoryName ); } static Repository connectToRepository( String repositoryName ); static void setRepositoryFactory( IRepositoryFactory factory ); static Document loadXMLFrom( String xml ); static Document loadXMLFrom( InputStream is ); static String asXml( Document document ); }### Answer:
@Test public void testConnectToRepository() throws Exception { IRepositoryFactory mock = mock( IRepositoryFactory.class ); PDIImportUtil.setRepositoryFactory( mock ); PDIImportUtil.connectToRepository( "foo" ); verify( mock, times( 1 ) ).connect( "foo" ); } |
### Question:
PDIImportUtil { public static Document loadXMLFrom( String xml ) throws SAXException, IOException { return loadXMLFrom( new ByteArrayInputStream( xml.getBytes() ) ); } static Repository connectToRepository( String repositoryName ); static void setRepositoryFactory( IRepositoryFactory factory ); static Document loadXMLFrom( String xml ); static Document loadXMLFrom( InputStream is ); static String asXml( Document document ); }### Answer:
@Test( timeout = 2000 ) public void whenLoadingMaliciousXmlFromStringParsingEndsWithNoErrorAndNullValueIsReturned() throws Exception { assertNull( PDIImportUtil.loadXMLFrom( MALICIOUS_XML ) ); }
@Test( timeout = 2000 ) public void whenLoadingMaliciousXmlFromInputStreamParsingEndsWithNoErrorAndNullValueIsReturned() throws Exception { assertNull( PDIImportUtil.loadXMLFrom( MALICIOUS_XML ) ); }
@Test public void whenLoadingLegalXmlFromStringNotNullDocumentIsReturned() throws Exception { final String trans = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<transformation>" + "</transformation>"; assertNotNull( PDIImportUtil.loadXMLFrom( trans ) ); } |
### Question:
Messages extends MessagesBase { private Messages() { super( BUNDLE_NAME ); } private Messages(); static Messages getInstance(); }### Answer:
@Test public void testMessages() { assertEquals( "Wrong message returned", "test message 1", Messages.getInstance().getString( "test.MESSAGE1" ) ); assertEquals( "Wrong message returned", "test message 2: A", Messages.getInstance().getString( "test.MESSAGE2", "A" ) ); assertEquals( "Wrong message returned", "test message 3: A B", Messages.getInstance().getString( "test.MESSAGE3", "A", "B" ) ); assertEquals( "Wrong message returned", "test message 4: A B C", Messages.getInstance().getString( "test.MESSAGE4", "A", "B", "C" ) ); assertEquals( "Wrong message returned", "test message 5: A B C D", Messages.getInstance().getString( "test.MESSAGE5", "A", "B", "C", "D" ) ); } |
### Question:
UnifiedRepositoryPurgeService implements IPurgeService { @Override public void deleteAllVersions( RepositoryElementInterface element ) throws KettleException { Serializable fileId = element.getObjectId().getId(); deleteAllVersions( fileId ); } UnifiedRepositoryPurgeService( IUnifiedRepository unifiedRepository ); @Override void deleteVersionsBeforeDate( RepositoryElementInterface element, Date beforeDate ); @Override void deleteVersionsBeforeDate( Serializable fileId, Date beforeDate ); @Override void deleteAllVersions( RepositoryElementInterface element ); @Override void deleteAllVersions( Serializable fileId ); @Override void deleteVersion( RepositoryElementInterface element, String versionId ); @Override void deleteVersion( Serializable fileId, Serializable versionId ); @Override void keepNumberOfVersions( RepositoryElementInterface element, int versionCount ); @Override void keepNumberOfVersions( Serializable fileId, int versionCount ); void doDeleteRevisions( PurgeUtilitySpecification purgeSpecification ); static DefaultUnifiedRepositoryWebService getRepoWs(); static DefaultUnifiedRepositoryWebService repoWs; }### Answer:
@Test public void deleteAllVersionsTest() throws KettleException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService( mockRepo ); String fileId = "1"; purgeService.deleteAllVersions( element1 ); verifyAllVersionsDeleted( versionListMap, mockRepo, "1" ); verify( mockRepo, never() ).deleteFileAtVersion( eq( "2" ), anyString() ); } |
### Question:
UnifiedRepositoryPurgeService implements IPurgeService { @Override public void deleteVersion( RepositoryElementInterface element, String versionId ) throws KettleException { String fileId = element.getObjectId().getId(); deleteVersion( fileId, versionId ); } UnifiedRepositoryPurgeService( IUnifiedRepository unifiedRepository ); @Override void deleteVersionsBeforeDate( RepositoryElementInterface element, Date beforeDate ); @Override void deleteVersionsBeforeDate( Serializable fileId, Date beforeDate ); @Override void deleteAllVersions( RepositoryElementInterface element ); @Override void deleteAllVersions( Serializable fileId ); @Override void deleteVersion( RepositoryElementInterface element, String versionId ); @Override void deleteVersion( Serializable fileId, Serializable versionId ); @Override void keepNumberOfVersions( RepositoryElementInterface element, int versionCount ); @Override void keepNumberOfVersions( Serializable fileId, int versionCount ); void doDeleteRevisions( PurgeUtilitySpecification purgeSpecification ); static DefaultUnifiedRepositoryWebService getRepoWs(); static DefaultUnifiedRepositoryWebService repoWs; }### Answer:
@Test public void deleteVersionTest() throws KettleException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService( mockRepo ); String fileId = "1"; String versionId = "103"; purgeService.deleteVersion( element1, versionId ); verify( mockRepo, times( 1 ) ).deleteFileAtVersion( fileId, versionId ); verify( mockRepo, never() ).deleteFileAtVersion( eq( "2" ), anyString() ); } |
### Question:
UnifiedRepositoryPurgeService implements IPurgeService { @Override public void deleteVersionsBeforeDate( RepositoryElementInterface element, Date beforeDate ) throws KettleException { try { Serializable fileId = element.getObjectId().getId(); deleteVersionsBeforeDate( fileId, beforeDate ); } catch ( Exception e ) { processDeleteException( e ); } } UnifiedRepositoryPurgeService( IUnifiedRepository unifiedRepository ); @Override void deleteVersionsBeforeDate( RepositoryElementInterface element, Date beforeDate ); @Override void deleteVersionsBeforeDate( Serializable fileId, Date beforeDate ); @Override void deleteAllVersions( RepositoryElementInterface element ); @Override void deleteAllVersions( Serializable fileId ); @Override void deleteVersion( RepositoryElementInterface element, String versionId ); @Override void deleteVersion( Serializable fileId, Serializable versionId ); @Override void keepNumberOfVersions( RepositoryElementInterface element, int versionCount ); @Override void keepNumberOfVersions( Serializable fileId, int versionCount ); void doDeleteRevisions( PurgeUtilitySpecification purgeSpecification ); static DefaultUnifiedRepositoryWebService getRepoWs(); static DefaultUnifiedRepositoryWebService repoWs; }### Answer:
@Test public void deleteVersionsBeforeDate() throws KettleException { IUnifiedRepository mockRepo = mock( IUnifiedRepository.class ); final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap( mockRepo ); UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService( mockRepo ); String fileId = "1"; Date beforeDate = getDate( "01/02/2006" ); purgeService.deleteVersionsBeforeDate( element1, beforeDate ); verifyDateBeforeDeletion( versionListMap, mockRepo, fileId, beforeDate ); verify( mockRepo, never() ).deleteFileAtVersion( eq( "2" ), anyString() ); } |
### Question:
RepositorySessionTimeoutHandler implements InvocationHandler { boolean connectedToRepository() { return repository.isConnected(); } RepositorySessionTimeoutHandler( ReconnectableRepository repository,
RepositoryConnectController repositoryConnectController ); @SuppressWarnings( "unchecked" ) @Override Object invoke( Object proxy, Method method, Object[] args ); }### Answer:
@Test public void connectedToRepository() { when( repository.isConnected() ).thenReturn( true ); assertTrue( timeoutHandler.connectedToRepository() ); }
@Test public void connectedToRepositoryReturnsFalse() { when( repository.isConnected() ).thenReturn( false ); assertFalse( timeoutHandler.connectedToRepository() ); } |
### Question:
RepositorySessionTimeoutHandler implements InvocationHandler { static IMetaStore wrapMetastoreWithTimeoutHandler( IMetaStore metaStore, SessionTimeoutHandler sessionTimeoutHandler ) { MetaStoreSessionTimeoutHandler metaStoreSessionTimeoutHandler = new MetaStoreSessionTimeoutHandler( metaStore, sessionTimeoutHandler ); return wrapObjectWithTimeoutHandler( metaStore, metaStoreSessionTimeoutHandler ); } RepositorySessionTimeoutHandler( ReconnectableRepository repository,
RepositoryConnectController repositoryConnectController ); @SuppressWarnings( "unchecked" ) @Override Object invoke( Object proxy, Method method, Object[] args ); }### Answer:
@Test public void wrapMetastoreWithTimeoutHandler() throws Throwable { IMetaStore metaStore = mock( IMetaStore.class ); doThrow( KettleRepositoryLostException.class ).when( metaStore ).createNamespace( any() ); SessionTimeoutHandler sessionTimeoutHandler = mock( SessionTimeoutHandler.class ); IMetaStore wrappedMetaStore = RepositorySessionTimeoutHandler.wrapMetastoreWithTimeoutHandler( metaStore, sessionTimeoutHandler ); wrappedMetaStore.createNamespace( "TEST_NAMESPACE" ); verify( sessionTimeoutHandler ).handle( any(), any(), any(), any() ); } |
### Question:
RepositoryServiceSessionTimeoutHandler implements InvocationHandler { @Override public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { try { return method.invoke( repositoryService, args ); } catch ( InvocationTargetException ex ) { return sessionTimeoutHandler.handle( repositoryService, ex.getCause(), method, args ); } } RepositoryServiceSessionTimeoutHandler( IRepositoryService repositoryService,
SessionTimeoutHandler sessionTimeoutHandler ); @Override Object invoke( Object proxy, Method method, Object[] args ); }### Answer:
@SuppressWarnings( "unchecked" ) @Test public void testHandlerCallOnException() throws Throwable { when( repositoryService.getUsers() ).thenThrow( KettleRepositoryLostException.class ); Method method = RepositorySecurityManager.class.getMethod( "getUsers" ); metaStoresessionTimeoutHandler.invoke( mock( Proxy.class ), method, new Object[0] ); verify( sessionTimeoutHandler ).handle( any(), any(), any(), any() ); } |
### Question:
SessionTimeoutHandler { public Object handle( Object objectToHandle, Throwable exception, Method method, Object[] args ) throws Throwable { if ( lookupForConnectTimeoutError( exception ) && !calledFromThisHandler() ) { try { return method.invoke( objectToHandle, args ); } catch ( InvocationTargetException ex2 ) { if ( !lookupForConnectTimeoutError( ex2 ) ) { throw ex2.getCause(); } } needToLogin.set( true ); synchronized ( this ) { if ( needToLogin.get() ) { boolean result = showLoginScreen( repositoryConnectController ); needToLogin.set( false ); if ( result ) { reinvoke.set( true ); return method.invoke( objectToHandle, args ); } reinvoke.set( false ); } } if ( reinvoke.get() ) { return method.invoke( objectToHandle, args ); } } throw exception; } SessionTimeoutHandler( RepositoryConnectController repositoryConnectController ); Object handle( Object objectToHandle, Throwable exception, Method method, Object[] args ); }### Answer:
@Test public void handle() throws Throwable { when( repository.readTransSharedObjects( any() ) ).thenReturn( mock( SharedObjects.class ) ); Method method = Repository.class.getMethod( "readTransSharedObjects", TransMeta.class ); sessionTimeoutHandler.handle( repository, mock( Exception.class ), method, new Object[] { mock( TransMeta.class ) } ); verify( sessionTimeoutHandler, never() ).showLoginScreen( any() ); } |
### Question:
MetaStoreSessionTimeoutHandler implements InvocationHandler { @Override public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { try { return method.invoke( metaStore, args ); } catch ( InvocationTargetException ex ) { return sessionTimeoutHandler.handle( metaStore, ex.getCause(), method, args ); } } MetaStoreSessionTimeoutHandler( IMetaStore metaStore, SessionTimeoutHandler sessionTimeoutHandler ); @Override Object invoke( Object proxy, Method method, Object[] args ); }### Answer:
@SuppressWarnings( "unchecked" ) @Test public void testHandlerCallOnException() throws Throwable { when( metaStore.getName() ).thenThrow( KettleRepositoryLostException.class ); Method method = IMetaStore.class.getMethod( "getName" ); metaStoresessionTimeoutHandler.invoke( mock( Proxy.class ), method, new Object[0] ); verify( sessionTimeoutHandler ).handle( any(), any(), any(), any() ); } |
### Question:
Log4jPipedAppender implements Appender { public void setPipedOutputStream( PipedOutputStream pipedOutputStream ) { this.pipedOutputStream = pipedOutputStream; } Log4jPipedAppender(); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); void doAppend( LoggingEvent event ); void setName( String name ); String getName(); void setErrorHandler( ErrorHandler arg0 ); ErrorHandler getErrorHandler(); void setLayout( Layout layout ); Layout getLayout(); boolean requiresLayout(); PipedOutputStream getPipedOutputStream(); void setPipedOutputStream( PipedOutputStream pipedOutputStream ); void setFilter( Filter filter ); }### Answer:
@Test public void setPipedOutputStream() { PipedOutputStream pipedOutputStream = new PipedOutputStream(); log4jPipedAppender.setPipedOutputStream( pipedOutputStream ); assertThat( log4jPipedAppender.getPipedOutputStream(), is( pipedOutputStream ) ); } |
### Question:
Log4jPipedAppender implements Appender { public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; try { pipedOutputStream.write( line.getBytes() ); } catch ( IOException e ) { System.out.println( "Unable to write to piped output stream : " + e.getMessage() ); } } Log4jPipedAppender(); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); void doAppend( LoggingEvent event ); void setName( String name ); String getName(); void setErrorHandler( ErrorHandler arg0 ); ErrorHandler getErrorHandler(); void setLayout( Layout layout ); Layout getLayout(); boolean requiresLayout(); PipedOutputStream getPipedOutputStream(); void setPipedOutputStream( PipedOutputStream pipedOutputStream ); void setFilter( Filter filter ); }### Answer:
@Test public void doAppend() throws IOException { PipedOutputStream pipedOutputStream = mock( PipedOutputStream.class ); LoggingEvent loggingEvent = mock( LoggingEvent.class ); Layout testLayout = mock( Layout.class ); when( testLayout.format( loggingEvent ) ).thenReturn( "LOG_TEST_LINE" ); log4jPipedAppender.setLayout( testLayout ); log4jPipedAppender.setPipedOutputStream( pipedOutputStream ); log4jPipedAppender.doAppend( loggingEvent ); verify( pipedOutputStream ).write( ( "LOG_TEST_LINE" + Const.CR ).getBytes() ); } |
### Question:
Log4jPipedAppender implements Appender { public void close() { try { pipedOutputStream.close(); } catch ( IOException e ) { System.out.println( "Unable to close piped output stream: " + e.getMessage() ); } } Log4jPipedAppender(); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); void doAppend( LoggingEvent event ); void setName( String name ); String getName(); void setErrorHandler( ErrorHandler arg0 ); ErrorHandler getErrorHandler(); void setLayout( Layout layout ); Layout getLayout(); boolean requiresLayout(); PipedOutputStream getPipedOutputStream(); void setPipedOutputStream( PipedOutputStream pipedOutputStream ); void setFilter( Filter filter ); }### Answer:
@Test public void close() throws IOException { PipedOutputStream pipedOutputStream = mock( PipedOutputStream.class ); log4jPipedAppender.setPipedOutputStream( pipedOutputStream ); log4jPipedAppender.close(); verify( pipedOutputStream ).close(); } |
### Question:
Log4jFileAppender implements Appender { public void doAppend( LoggingEvent event ) { String line = layout.format( event ) + Const.CR; try { fileOutputStream.write( line.getBytes( Const.XML_ENCODING ) ); } catch ( IOException e ) { System.out.println( "Unable to close Logging file [" + file.getName() + "] : " + e.getMessage() ); } } Log4jFileAppender( FileObject file ); Log4jFileAppender( FileObject file, boolean append ); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); void doAppend( LoggingEvent event ); void setName( String name ); String getName(); void setErrorHandler( ErrorHandler arg0 ); ErrorHandler getErrorHandler(); void setLayout( Layout layout ); Layout getLayout(); boolean requiresLayout(); FileObject getFile(); void setFilename( FileObject file ); OutputStream getFileOutputStream(); void setFileOutputStream( OutputStream fileOutputStream ); void setFilter( Filter filter ); }### Answer:
@Test public void doAppend() throws IOException { LoggingEvent loggingEvent = mock( LoggingEvent.class ); Layout testLayout = mock( Layout.class ); when( testLayout.format( loggingEvent ) ).thenReturn( "LOG_TEST_LINE" ); log4jFileAppender.setLayout( testLayout ); log4jFileAppender.doAppend( loggingEvent ); verify( outputStream ).write( ( "LOG_TEST_LINE" + Const.CR ).getBytes() ); } |
### Question:
Log4jFileAppender implements Appender { public void close() { try { fileOutputStream.close(); } catch ( IOException e ) { System.out.println( "Unable to close Logging file [" + file.getName() + "] : " + e.getMessage() ); } } Log4jFileAppender( FileObject file ); Log4jFileAppender( FileObject file, boolean append ); void addFilter( Filter filter ); Filter getFilter(); void clearFilters(); void close(); void doAppend( LoggingEvent event ); void setName( String name ); String getName(); void setErrorHandler( ErrorHandler arg0 ); ErrorHandler getErrorHandler(); void setLayout( Layout layout ); Layout getLayout(); boolean requiresLayout(); FileObject getFile(); void setFilename( FileObject file ); OutputStream getFileOutputStream(); void setFileOutputStream( OutputStream fileOutputStream ); void setFilter( Filter filter ); }### Answer:
@Test public void close() throws IOException { log4jFileAppender.close(); verify( outputStream ).close(); } |
### Question:
GlobalMessages extends AbstractMessageHandler { public static ResourceBundle getBundle( String packageName ) throws MissingResourceException { return getBundle( packageName, GlobalMessages.getInstance().getClass() ); } GlobalMessages(); static synchronized MessageHandler getInstance(); static synchronized Locale getLocale(); static synchronized void setLocale( Locale newLocale ); static ResourceBundle getBundle( String packageName ); static ResourceBundle getBundle( String packageName, Class<?> resourceClass ); static ResourceBundle getBundle( Locale locale, String packageName ); static ResourceBundle getBundle( Locale locale, String packageName, Class<?> resourceClass ); @Override String getString( String key ); @Override String getString( String packageName, String key ); @Override String getString( String packageName, String key, String... parameters ); @Override String getString( String packageName, String key, Class<?> resourceClass, String... parameters ); static final String[] localeCodes; static final String[] localeDescr; }### Answer:
@Test public void testGetBundleNewUTF8() throws Exception { res = GlobalMessages.getBundle( Locale.JAPAN, "org/pentaho/di/i18n/messages/test_utf8_messages" ); assertEquals( "環境変数の選択", res.getString( "System.Dialog.SelectEnvironmentVar.Title" ) ); res = GlobalMessages.getBundle( Locale.CHINA, "org/pentaho/di/i18n/messages/test_utf8_messages" ); assertEquals( "选择一个环境变量", res.getString( "System.Dialog.SelectEnvironmentVar.Title" ) ); } |
### Question:
MetaStoreConst { public static IMetaStore openLocalPentahoMetaStore() throws MetaStoreException { return MetaStoreConst.openLocalPentahoMetaStore( true ); } static final String getDefaultPentahoMetaStoreLocation(); static IMetaStore openLocalPentahoMetaStore(); static IMetaStore openLocalPentahoMetaStore( boolean allowCreate ); static final String DB_ATTR_ID_DESCRIPTION; static final String DB_ATTR_ID_PLUGIN_ID; static final String DB_ATTR_ID_ACCESS_TYPE; static final String DB_ATTR_ID_HOSTNAME; static final String DB_ATTR_ID_PORT; static final String DB_ATTR_ID_DATABASE_NAME; static final String DB_ATTR_ID_USERNAME; static final String DB_ATTR_ID_PASSWORD; static final String DB_ATTR_ID_SERVERNAME; static final String DB_ATTR_ID_DATA_TABLESPACE; static final String DB_ATTR_ID_INDEX_TABLESPACE; static boolean disableMetaStore; static final String DB_ATTR_DRIVER_CLASS; static final String DB_ATTR_JDBC_URL; static final String DB_ATTR_ID_ATTRIBUTES; }### Answer:
@Test public void testOpenLocalPentahoMetaStore() throws Exception { MetaStoreConst.disableMetaStore = false; File tempDir = Files.createTempDir(); String tempPath = tempDir.getAbsolutePath(); System.setProperty( Const.PENTAHO_METASTORE_FOLDER, tempPath ); String metaFolder = tempPath + File.separator + XmlUtil.META_FOLDER_NAME; assertNotNull( MetaStoreConst.openLocalPentahoMetaStore() ); assertTrue( ( new File( metaFolder ) ).exists() ); MetaStoreConst.disableMetaStore = true; assertNull( MetaStoreConst.openLocalPentahoMetaStore() ); MetaStoreConst.disableMetaStore = false; assertNotNull( MetaStoreConst.openLocalPentahoMetaStore( false ) ); FileUtils.deleteDirectory( new File( metaFolder ) ); assertNull( MetaStoreConst.openLocalPentahoMetaStore( false ) ); assertFalse( ( new File( metaFolder ) ).exists() ); } |
### Question:
StringObjectId implements ObjectId, Comparable<StringObjectId> { public StringObjectId( String id ) { this.id = id; } StringObjectId( String id ); StringObjectId( ObjectId objectId ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override int compareTo( StringObjectId o ); @Override String toString(); @Override String getId(); }### Answer:
@Test public void testStringObjectId() { String expectedId = UUID.randomUUID().toString(); StringObjectId obj = new StringObjectId( expectedId ); assertEquals( expectedId, obj.getId() ); assertEquals( expectedId, obj.toString() ); assertEquals( expectedId.hashCode(), obj.hashCode() ); assertFalse( obj.equals( null ) ); assertTrue( obj.equals( obj ) ); assertEquals( 0, obj.compareTo( obj ) ); StringObjectId clone = new StringObjectId( obj ); assertNotSame( obj, clone ); assertEquals( obj.getId(), clone.getId() ); } |
### Question:
DateCache { public DateCache() { cache = new HashMap<String, Date>(); } DateCache(); void populate( String datePattern, int fromYear, int toYear ); void addDate( String dateString, Date date ); Date lookupDate( String dateString ); int getSize(); static void main( String[] args ); }### Answer:
@SuppressWarnings( "deprecation" ) @Test public void testDateCache() { DateCache cache = new DateCache(); cache.populate( "yyyy-MM-dd", 2016, 2016 ); assertEquals( 366, cache.getSize() ); assertEquals( Calendar.FEBRUARY, cache.lookupDate( "2016-02-29" ).getMonth() ); assertEquals( 29, cache.lookupDate( "2016-02-29" ).getDate() ); assertEquals( ( 2016 - 1900 ), cache.lookupDate( "2016-02-29" ).getYear() ); } |
### Question:
LookupReferencesException extends KettleException { public String objectTypePairsToString() { StringBuilder result = new StringBuilder(); for ( Map.Entry entry : objectTypePairs.entrySet() ) { if ( entry.getKey() != null ) { result.append( Const.CR ); result.append( "\"" ); result.append( entry.getKey() ); result.append( "\"" ); result.append( " [" ); result.append( entry.getValue() ); result.append( "] " ); } } return result.toString(); } LookupReferencesException( Map<String, RepositoryObjectType> objectTypePairs ); LookupReferencesException( String message, Map<String, RepositoryObjectType> objectTypePairs ); LookupReferencesException( Throwable cause, Map<String, RepositoryObjectType> objectTypePairs ); LookupReferencesException( String message, Throwable cause,
Map<String, RepositoryObjectType> objectTypePairs ); String objectTypePairsToString(); static final long serialVersionUID; }### Answer:
@Test public void testObjectTypePairsToString() throws Exception { Exception cause = new NullPointerException(); Map<String, RepositoryObjectType> notFoundedReferences = new LinkedHashMap<String, RepositoryObjectType>(); String pathToTransStub = "/path/Trans.ktr"; String pathToJobStub = "/path/Job.ktr"; notFoundedReferences.put( pathToTransStub, RepositoryObjectType.TRANSFORMATION ); notFoundedReferences.put( pathToJobStub, RepositoryObjectType.JOB ); String expectedOutput = System.lineSeparator() + "\"/path/Trans.ktr\" [transformation] " + System.lineSeparator() + "\"/path/Job.ktr\" [job] "; try { throw new LookupReferencesException( cause, notFoundedReferences ); } catch ( LookupReferencesException testedException ) { String actual = testedException.objectTypePairsToString(); assertEquals( expectedOutput, actual ); assertNotNull( testedException.getCause() ); } } |
### Question:
DataHandler extends AbstractXulEventHandler { public void clearOptionsData() { getControls(); if ( optionsParameterTree != null ) { optionsParameterTree.getRootChildren().removeAll(); } } DataHandler(); void loadConnectionData(); void loadAccessData(); void editOptions( int index ); void clearOptionsData(); void getOptionHelp(); void setDeckChildIndex(); void onPoolingCheck(); void onClusterCheck(); Object getData(); void setData( Object data ); void pushCache(); void popCache(); void onCancel(); void onOK(); void testDatabaseConnection(); void restoreDefaults(); void poolingRowChange( int idx ); void disablePortIfInstancePopulated(); void handleUseSecurityCheckbox(); static final SortedMap<String, DatabaseInterface> connectionMap; static final Map<String, String> connectionNametoID; }### Answer:
@Test public void testClearOptionsData() throws Exception { } |
### Question:
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public boolean putRow( RowMetaInterface rowMeta, Object[] rowData ) { this.rowMeta = rowMeta; this.row = rowData; return true; } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }### Answer:
@Test public void testPutRow() throws Exception { rowSet.putRow( new RowMeta(), row ); assertSame( row, rowSet.getRow() ); } |
### Question:
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ) { return putRow( rowMeta, rowData ); } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }### Answer:
@Test public void testPutRowWait() throws Exception { rowSet.putRowWait( new RowMeta(), row, 1, TimeUnit.SECONDS ); assertSame( row, rowSet.getRowWait( 1, TimeUnit.SECONDS ) ); } |
### Question:
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public Object[] getRowImmediate() { return getRow(); } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }### Answer:
@Test public void testGetRowImmediate() throws Exception { rowSet.putRow( new RowMeta(), row ); assertSame( row, rowSet.getRowImmediate() ); } |
### Question:
SingleRowRowSet extends BaseRowSet implements Comparable<RowSet>, RowSet { @Override public int size() { return row == null ? 0 : 1; } @Override Object[] getRow(); @Override Object[] getRowImmediate(); @Override Object[] getRowWait( long timeout, TimeUnit tu ); @Override boolean putRow( RowMetaInterface rowMeta, Object[] rowData ); @Override boolean putRowWait( RowMetaInterface rowMeta, Object[] rowData, long time, TimeUnit tu ); @Override int size(); @Override void clear(); }### Answer:
@Test public void testSize() throws Exception { assertEquals( 0, rowSet.size() ); rowSet.putRow( new RowMeta(), row ); assertEquals( 1, rowSet.size() ); rowSet.clear(); assertEquals( 0, rowSet.size() ); } |
### Question:
DateDetector { public static String getRegexpByDateFormat( String dateFormat ) { return getRegexpByDateFormat( dateFormat, null ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }### Answer:
@Test public void testGetRegexpByDateFormat() { assertNull( DateDetector.getRegexpByDateFormat( null ) ); assertEquals( SAMPLE_REGEXP, DateDetector.getRegexpByDateFormat( SAMPLE_DATE_FORMAT ) ); }
@Test public void testGetRegexpByDateFormatLocale() { assertNull( DateDetector.getRegexpByDateFormat( null, null ) ); assertNull( DateDetector.getRegexpByDateFormat( null, LOCALE_en_US ) ); assertNull( DateDetector.getRegexpByDateFormat( SAMPLE_DATE_FORMAT_US ) ); assertEquals( SAMPLE_REGEXP_US, DateDetector.getRegexpByDateFormat( SAMPLE_DATE_FORMAT_US, LOCALE_en_US ) ); } |
### Question:
DateDetector { public static String getDateFormatByRegex( String regex ) { return getDateFormatByRegex( regex, null ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }### Answer:
@Test public void testGetDateFormatByRegex() { assertNull( DateDetector.getDateFormatByRegex( null ) ); assertEquals( SAMPLE_DATE_FORMAT, DateDetector.getDateFormatByRegex( SAMPLE_REGEXP ) ); }
@Test public void testGetDateFormatByRegexLocale() { assertNull( DateDetector.getDateFormatByRegex( null, null ) ); assertNull( DateDetector.getDateFormatByRegex( null, LOCALE_en_US ) ); assertEquals( SAMPLE_DATE_FORMAT, DateDetector.getDateFormatByRegex( SAMPLE_REGEXP_US ) ); assertEquals( SAMPLE_DATE_FORMAT_US, DateDetector.getDateFormatByRegex( SAMPLE_REGEXP_US, LOCALE_en_US ) ); } |
### Question:
DateDetector { public static Date getDateFromString( String dateString ) throws ParseException { String dateFormat = detectDateFormat( dateString ); if ( dateFormat == null ) { throw new ParseException( "Unknown date format.", 0 ); } return getDateFromStringByFormat( dateString, dateFormat ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }### Answer:
@Test public void testGetDateFromString() throws ParseException { assertEquals( SAMPLE_DATE_US, DateDetector.getDateFromString( SAMPLE_DATE_STRING_US ) ); try { DateDetector.getDateFromString( null ); } catch ( ParseException e ) { } }
@Test public void testGetDateFromStringLocale() throws ParseException { assertEquals( SAMPLE_DATE_US, DateDetector.getDateFromString( SAMPLE_DATE_STRING_US, LOCALE_en_US ) ); try { DateDetector.getDateFromString( null ); } catch ( ParseException e ) { } try { DateDetector.getDateFromString( null, null ); } catch ( ParseException e ) { } } |
### Question:
DateDetector { public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException { if ( dateFormat == null ) { throw new ParseException( "Unknown date format. Format is null. ", 0 ); } if ( dateString == null ) { throw new ParseException( "Unknown date string. Date string is null. ", 0 ); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat ); simpleDateFormat.setLenient( false ); return simpleDateFormat.parse( dateString ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }### Answer:
@Test public void testGetDateFromStringByFormat() throws ParseException { assertEquals( SAMPLE_DATE, DateDetector.getDateFromStringByFormat( SAMPLE_DATE_STRING, SAMPLE_DATE_FORMAT ) ); try { DateDetector.getDateFromStringByFormat( SAMPLE_DATE_STRING, null ); } catch ( ParseException e ) { } try { DateDetector.getDateFromStringByFormat( null, SAMPLE_DATE_FORMAT ); } catch ( ParseException e ) { } } |
### Question:
DateDetector { public static String detectDateFormat( String dateString ) { return detectDateFormat( dateString, null ); } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }### Answer:
@Test public void testDetectDateFormat() { assertEquals( SAMPLE_DATE_FORMAT, DateDetector.detectDateFormat( SAMPLE_DATE_STRING, LOCALE_es ) ); assertNull( DateDetector.detectDateFormat( null ) ); } |
### Question:
DateDetector { public static boolean isValidDate( String dateString, String dateFormat ) { try { getDateFromStringByFormat( dateString, dateFormat ); return true; } catch ( ParseException e ) { return false; } } private DateDetector(); static String getRegexpByDateFormat( String dateFormat ); static String getRegexpByDateFormat( String dateFormat, String locale ); static String getDateFormatByRegex( String regex ); static String getDateFormatByRegex( String regex, String locale ); static Date getDateFromString( String dateString ); static Date getDateFromString( String dateString, String locale ); static Date getDateFromStringByFormat( String dateString, String dateFormat ); static String detectDateFormat( String dateString ); static String detectDateFormat( String dateString, String locale ); static String detectDateFormatBiased( String dateString, String locale, String desiredKey ); static BidiMap getDateFormatToRegExps( String locale ); static boolean isValidDate( String dateString, String dateFormat ); static boolean isValidDate( String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString ); static boolean isValidDateFormatToStringDate( String dateFormat, String dateString, String locale ); }### Answer:
@Test public void testIsValidDate() { assertTrue( DateDetector.isValidDate( SAMPLE_DATE_STRING_US ) ); assertFalse( DateDetector.isValidDate( null ) ); assertTrue( DateDetector.isValidDate( SAMPLE_DATE_STRING, SAMPLE_DATE_FORMAT ) ); assertFalse( DateDetector.isValidDate( SAMPLE_DATE_STRING, null ) ); } |
### Question:
StringEvaluator { public int getCount() { return count; } StringEvaluator(); StringEvaluator( boolean tryTrimming ); StringEvaluator( boolean tryTrimming, List<String> numberFormats, List<String> dateFormats ); StringEvaluator( boolean tryTrimming, String[] numberFormats, String[] dateFormats ); void evaluateString( String value ); StringEvaluationResult getAdvicedResult(); String[] getDateFormats(); String[] getNumberFormats(); Set<String> getValues(); List<StringEvaluationResult> getStringEvaluationResults(); int getCount(); int getMaxLength(); }### Answer:
@Test public void testGetCount() { List<String> strings = Arrays.asList( "02/29/2000", "03/29/2000" ); for ( String string : strings ) { evaluator.evaluateString( string ); } assertEquals( strings.size(), evaluator.getCount() ); } |
### Question:
EnvUtil { public static Locale createLocale( String localeCode ) { Locale resultLocale = null; if ( !Utils.isEmpty( localeCode ) ) { StringTokenizer parser = new StringTokenizer( localeCode, "_" ); if ( parser.countTokens() == 2 ) { resultLocale = new Locale( parser.nextToken(), parser.nextToken() ); } else { resultLocale = new Locale( localeCode ); } } return resultLocale; } static Properties readProperties( final String fileName ); static void environmentInit(); static void applyKettleProperties( Map<?, ?> kettleProperties ); static void applyKettleProperties( Map<?, ?> kettleProperties, boolean override ); static void addInternalVariables( Properties prop ); static final String[] getEnvironmentVariablesForRuntimeExec(); static final String getSystemPropertyStripQuotes( String key, String def ); static final String getSystemProperty( String key, String def ); static final String getSystemProperty( String key ); static Locale createLocale( String localeCode ); static TimeZone createTimeZone( String timeZoneId ); static String[] getTimeZones(); static String[] getLocaleList(); }### Answer:
@Test public void createLocale_Null() throws Exception { assertNull( EnvUtil.createLocale( null ) ); }
@Test public void createLocale_Empty() throws Exception { assertNull( EnvUtil.createLocale( "" ) ); }
@Test public void createLocale_SingleCode() throws Exception { assertEquals( Locale.ENGLISH, EnvUtil.createLocale( "en" ) ); }
@Test public void createLocale_DoubleCode() throws Exception { assertEquals( Locale.US, EnvUtil.createLocale( "en_US" ) ); } |
### Question:
TemporaryCacheManager { public void cacheSmallBlock(SmallBlock smallBlock) { smallBlockCacheMap.put(smallBlock.getHeader().getHash(), smallBlock); } private TemporaryCacheManager(); static TemporaryCacheManager getInstance(); void cacheSmallBlock(SmallBlock smallBlock); void cacheSmallBlockWithRequest(NulsDigestData requestHash, SmallBlock smallBlock); SmallBlock getSmallBlockByRequest(NulsDigestData requestHash); SmallBlock getSmallBlockByHash(NulsDigestData blockHash); boolean cacheTx(Transaction tx); Transaction getTx(NulsDigestData hash); void removeSmallBlock(NulsDigestData hash); void clear(); void destroy(); boolean containsTx(NulsDigestData txHash); int getSmallBlockCount(); int getTxCount(); }### Answer:
@Test public void cacheSmallBlock() { SmallBlock smallBlock = new SmallBlock(); BlockHeader header = new BlockHeader(); NulsDigestData hash = NulsDigestData.calcDigestData("abcdefg".getBytes()); header.setHash(hash); manager.cacheSmallBlock(smallBlock); assertTrue(true); this.getSmallBlock(hash, smallBlock); this.removeSmallBlock(hash); manager.cacheSmallBlock(smallBlock); this.clear(); } |
### Question:
RoundManager { public MeetingRound getRoundByIndex(long roundIndex) { MeetingRound round = null; for (int i = roundList.size() - 1; i >= 0; i--) { round = roundList.get(i); if (round.getIndex() == roundIndex) { break; } } return round; } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }### Answer:
@Test public void testGetRoundByIndex() { assertNotNull(roundManager); assertNotNull(roundManager.getChain()); long index = 1002L; assertEquals(0, roundManager.getRoundList().size()); MeetingRound round = new MeetingRound(); round.setIndex(index); roundManager.addRound(round); assertEquals(1, roundManager.getRoundList().size()); MeetingRound round2 = roundManager.getRoundByIndex(index); assertNotNull(round2); assertEquals(round, round2); } |
### Question:
RoundManager { public boolean clearRound(int count) { Lockers.ROUND_LOCK.lock(); boolean doit = false; try { while (roundList.size() > count) { doit = true; roundList.remove(0); } if (doit) { MeetingRound round = roundList.get(0); round.setPreRound(null); } return true; } finally { Lockers.ROUND_LOCK.unlock(); } } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }### Answer:
@Test public void testClearRound() { MeetingRound round = new MeetingRound(); round.setIndex(1l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(2l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(3l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(4l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(5l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(6l); roundManager.addRound(round); round = new MeetingRound(); round.setIndex(7l); roundManager.addRound(round); assertEquals(7, roundManager.getRoundList().size()); assertEquals(7L, roundManager.getCurrentRound().getIndex()); boolean success = roundManager.clearRound(3); assert(success); assertEquals(3, roundManager.getRoundList().size()); assertEquals(7L, roundManager.getCurrentRound().getIndex()); } |
### Question:
RoundManager { public MeetingRound initRound() { MeetingRound currentRound = resetRound(false); if (currentRound.getPreRound() == null) { BlockExtendsData extendsData = null; List<BlockHeader> blockHeaderList = chain.getAllBlockHeaderList(); for (int i = blockHeaderList.size() - 1; i >= 0; i--) { BlockHeader blockHeader = blockHeaderList.get(i); extendsData = new BlockExtendsData(blockHeader.getExtend()); if (extendsData.getRoundIndex() < currentRound.getIndex()) { break; } } MeetingRound preRound = getNextRound(extendsData, false); currentRound.setPreRound(preRound); } return currentRound; } RoundManager(Chain chain); MeetingRound getRoundByIndex(long roundIndex); void addRound(MeetingRound meetingRound); void checkIsNeedReset(); boolean clearRound(int count); MeetingRound getCurrentRound(); MeetingRound initRound(); MeetingRound resetRound(boolean isRealTime); MeetingRound getNextRound(BlockExtendsData roundData, boolean isRealTime); Chain getChain(); List<MeetingRound> getRoundList(); AccountService getAccountService(); }### Answer:
@Test public void testInitRound() { assertNotNull(roundManager); assertNotNull(roundManager.getChain()); Chain chain = roundManager.getChain(); assertNotNull(chain.getEndBlockHeader()); assert(chain.getAllBlockList().size() > 0); MeetingRound round = roundManager.initRound(); assertNotNull(round); assertEquals(round.getIndex(), 2L); Assert.assertEquals(round.getStartTime(), ProtocolConstant.BLOCK_TIME_INTERVAL_MILLIS + 1L); MeetingRound round2 = roundManager.getNextRound(null, false); assertNotNull(round2); assertEquals(round.getIndex(), round2.getIndex()); assertEquals(round.getStartTime(), round2.getStartTime()); round2 = roundManager.getNextRound(null, true); assertNotNull(round2); assert(round.getIndex() < round2.getIndex()); assert(round.getStartTime() < round2.getStartTime()); assertEquals("", 0d, round2.getTotalWeight(), 2200000d); } |
### Question:
ConsensusTool { public static SmallBlock getSmallBlock(Block block) { SmallBlock smallBlock = new SmallBlock(); smallBlock.setHeader(block.getHeader()); List<NulsDigestData> txHashList = new ArrayList<>(); for (Transaction tx : block.getTxs()) { txHashList.add(tx.getHash()); if (tx.isSystemTx()) { smallBlock.addBaseTx(tx); } } smallBlock.setTxHashList(txHashList); return smallBlock; } static SmallBlock getSmallBlock(Block block); static Block createBlock(BlockData blockData, Account account); static CoinBaseTransaction createCoinBaseTx(MeetingMember member, List<Transaction> txList, MeetingRound localRound, long unlockHeight); static YellowPunishTransaction createYellowPunishTx(Block preBlock, MeetingMember self, MeetingRound round); static CoinData getStopAgentCoinData(Agent agent, long lockTime); static CoinData getStopAgentCoinData(Agent agent, long lockTime, Long hight); static CoinData getStopAgentCoinData(byte[] address, long lockTime); static byte[] getStateRoot(BlockHeader blockHeader); }### Answer:
@Test public void testGetSmallBlock() { Block block = createBlock(); SmallBlock smallBlock = ConsensusTool.getSmallBlock(block); assertNotNull(smallBlock); assertEquals(smallBlock.getHeader(), block.getHeader()); assertEquals(smallBlock.getSubTxList().size() , 0); assertEquals(smallBlock.getTxHashList().get(0), block.getTxs().get(0).getHash()); } |
### Question:
RandomSeedUtils { public static byte[] createRandomSeed() { BigInteger value = new BigInteger(256, new Random()); byte[] result = value.toByteArray(); if (result.length > 32) { byte[] temp = new byte[32]; System.arraycopy(result, result.length - 32, temp, 0, 32); result = temp; } else if (result.length < 32) { byte[] temp = new byte[32]; System.arraycopy(result, 0, temp, 0, result.length); result = temp; } return result; } static byte[] createRandomSeed(); static byte[] getLastDigestEightBytes(byte[] bytes); static RandomSeedStatusPo CACHE_SEED; }### Answer:
@Test public void createRandomSeed() { for (int i = 0; i < 1000000; i++) { byte[] result = RandomSeedUtils.createRandomSeed(); assertEquals(result.length, 32); } } |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.