Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEST] Tests for org.pentaho.di.core package
- Loading branch information
1 parent
001a0ab
commit 39a4d3d
Showing
18 changed files
with
1,601 additions
and
155 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
core/test-src/org/pentaho/di/core/BlockingListeningRowSetTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2015 by Pentaho : http://www.pentaho.com | ||
* | ||
******************************************************************************* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
******************************************************************************/ | ||
package org.pentaho.di.core; | ||
|
||
import org.junit.Test; | ||
import org.pentaho.di.core.row.RowMeta; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class BlockingListeningRowSetTest { | ||
@Test | ||
public void testClass() { | ||
BlockingListeningRowSet rowSet = new BlockingListeningRowSet( 1 ); | ||
assertEquals( 0, rowSet.size() ); | ||
final Object[] row = new Object[]{}; | ||
final RowMeta meta = new RowMeta(); | ||
rowSet.putRow( meta, row ); | ||
assertSame( meta, rowSet.getRowMeta() ); | ||
assertEquals( 1, rowSet.size() ); | ||
assertFalse( rowSet.isBlocking() ); | ||
assertSame( row, rowSet.getRow() ); | ||
assertEquals( 0, rowSet.size() ); | ||
rowSet.putRow( meta, row ); | ||
assertSame( row, rowSet.getRowImmediate() ); | ||
rowSet.putRow( meta, row ); | ||
assertEquals( 1, rowSet.size() ); | ||
rowSet.clear(); | ||
assertEquals( 0, rowSet.size() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2015 by Pentaho : http://www.pentaho.com | ||
* | ||
******************************************************************************* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
******************************************************************************/ | ||
package org.pentaho.di.core; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class CheckResultTest { | ||
@Test | ||
public void testClass() { | ||
final int type = CheckResultInterface.TYPE_RESULT_ERROR; | ||
final String text = "some text"; | ||
final String sourceMetaName = "meta name"; | ||
final CheckResultSourceInterface sourceMeta = mock( CheckResultSourceInterface.class ); | ||
final String errorCode = "error code"; | ||
|
||
CheckResult cr = new CheckResult(); | ||
assertEquals( CheckResultInterface.TYPE_RESULT_NONE, cr.getType() ); | ||
assertTrue( cr.getTypeDesc() != null && cr.getTypeDesc().isEmpty() ); | ||
cr.setType( type ); | ||
assertEquals( type, cr.getType() ); | ||
|
||
assertTrue( cr.getText().isEmpty() ); | ||
cr.setText( text ); | ||
assertSame( text, cr.getText() ); | ||
|
||
assertNull( null, cr.getSourceInfo() ); | ||
|
||
assertNull( cr.getErrorCode() ); | ||
cr.setErrorCode( errorCode ); | ||
assertSame( errorCode, cr.getErrorCode() ); | ||
|
||
when( sourceMeta.getName() ).thenReturn( sourceMetaName ); | ||
cr = new CheckResult( type, text, sourceMeta ); | ||
assertSame( sourceMeta, cr.getSourceInfo() ); | ||
assertTrue( cr.getTypeDesc() != null && !cr.getTypeDesc().isEmpty() ); | ||
final String stringValue = String.format( "%s: %s (%s)", cr.getTypeDesc(), text, sourceMetaName ); | ||
assertEquals( stringValue, cr.toString() ); | ||
|
||
cr = new CheckResult( type, errorCode, text, sourceMeta ); | ||
assertSame( errorCode, cr.getErrorCode() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho Data Integration | ||
* | ||
* Copyright (C) 2002-2015 by Pentaho : http://www.pentaho.com | ||
* | ||
******************************************************************************* | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
******************************************************************************/ | ||
package org.pentaho.di.core; | ||
|
||
import org.junit.Test; | ||
import org.pentaho.di.core.database.DatabaseMeta; | ||
import org.pentaho.di.core.database.MySQLDatabaseMeta; | ||
import org.pentaho.di.core.database.SAPR3DatabaseMeta; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ConstDBTest { | ||
|
||
@Test | ||
public void testSelectSAPR3Databases() throws Exception { | ||
KettleClientEnvironment.init(); | ||
final DatabaseMeta mysqlMeta = new DatabaseMeta(); | ||
mysqlMeta.setDatabaseInterface( new MySQLDatabaseMeta() ); | ||
final DatabaseMeta sapR3Meta = new DatabaseMeta(); | ||
sapR3Meta.setDatabaseInterface( new SAPR3DatabaseMeta() ); | ||
List<DatabaseMeta> databaseMetas = new ArrayList<>(); | ||
databaseMetas.add( mysqlMeta ); | ||
databaseMetas.add( sapR3Meta ); | ||
|
||
List<DatabaseMeta> sapR3Metas = ConstDB.selectSAPR3Databases( databaseMetas ); | ||
assertEquals( 1, sapR3Metas.size() ); | ||
assertSame( sapR3Meta, sapR3Metas.get( 0 ) ); | ||
} | ||
} |
Oops, something went wrong.