/** * @param bool * boolean to test. * @throws IllegalArgumentException * if bool is false. */ public static void assertTrue( final boolean bool ) throws IllegalArgumentException { assertTrue( bool, "Value cannot be false" ); }
private static void assertCompareDateInterval( DimensionCache dc, Object from1, Object to1, Object from2, Object to2, int expectedValue ) { final int actualValue = dc.compare( new Object[] { from1, to1 }, new Object[] { from2, to2 } ); boolean success = ( expectedValue == 0 && actualValue == 0 ) // || ( expectedValue < 0 && actualValue < 0 ) // || ( expectedValue > 0 && actualValue > 0 ); Assert.assertTrue( success, "{0} expected, {1} actual. compare( [({2}), ({3})], [({4}), ({5})] )", // expectedValue, actualValue, from1, to1, from2, to2 ); }
@Test public void testPatternAndExcludePatternNull() throws Exception { fileSelector = new JobEntryZipFile.ZipJobEntryPatternFileSelector( null, null ); boolean includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertTrue( includeFile ); Mockito.when( fileNameMock.getBaseName() ).thenReturn( EXCLUDE_PATTERN_FILE_NAME ); includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertTrue( includeFile ); }
@Test public void testMatchesPattern() throws Exception { boolean includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertTrue( includeFile ); }
private void testAddDiffHandlersForSameEvent( Message messageEvent, MessageEventHandler handler, MessageEventHandler handler2 ) throws KettleException { messageEventService.addHandler( messageEvent, handler ); messageEventService.addHandler( messageEvent, handler2 ); assertTrue( messageEventService.getHandlersFor( messageEvent ).size() == 2 ); assertTrue( handler.getIdentifier() .equals( messageEventService.getHandlersFor( messageEvent ).get( 0 ).getIdentifier() ) ); assertTrue( handler2.getIdentifier() .equals( messageEventService.getHandlersFor( messageEvent ).get( 1 ).getIdentifier() ) ); } }
@Test public void testOperationAddHandler() throws KettleException { messageEventService.addHandler( operationMessageEvent, messageEventHandler ); assertTrue( messageEventService.getHandlersFor( operationMessageEvent ).size() == 1 ); assertTrue( messageEventHandler.getIdentifier() .equals( messageEventService.getHandlersFor( operationMessageEvent ).get( 0 ).getIdentifier() ) ); }
@Test public void testTranformationAddHandler() throws KettleException { messageEventService.addHandler( transformationMessageEvent, messageEventHandler ); assertTrue( messageEventService.getHandlersFor( transformationMessageEvent ).size() == 1 ); assertTrue( messageEventHandler.getIdentifier() .equals( messageEventService.getHandlersFor( transformationMessageEvent ).get( 0 ).getIdentifier() ) ); }
@Test public void testTransformationHasHandler() throws KettleException { addHandlers( transformationMessageEvent, messageEventHandler, messageEventHandler2 ); assertTrue( messageEventService.hasHandlers( transformationMessageEvent ) ); }
@Test public void testOperationHasHandler() throws KettleException { addHandlers( operationMessageEvent, messageEventHandler, messageEventHandler2 ); assertTrue( messageEventService.hasHandlers( operationMessageEvent ) ); }
@Test public void testExcludePatternNull() throws Exception { fileSelector = new JobEntryZipFile.ZipJobEntryPatternFileSelector( Pattern.compile( PATTERN ), null ); boolean includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertTrue( includeFile ); Mockito.when( fileNameMock.getBaseName() ).thenReturn( EXCLUDE_PATTERN_FILE_NAME ); includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertFalse( includeFile ); }
@Test public void testPatternNull() throws Exception { fileSelector = new JobEntryZipFile.ZipJobEntryPatternFileSelector( null, Pattern.compile( EXCLUDE_PATTERN ) ); boolean includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertTrue( includeFile ); Mockito.when( fileNameMock.getBaseName() ).thenReturn( EXCLUDE_PATTERN_FILE_NAME ); includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertFalse( includeFile ); }
Assert.assertTrue( passThroughKeys.get( 0 ).startsWith( "0_file" ) ); Assert.assertTrue( passThroughKeys.get( 0 ).endsWith( "filename1" ) ); Assert.assertTrue( passThroughKeys.get( 1 ).startsWith( "1_file" ) ); Assert.assertTrue( passThroughKeys.get( 1 ).endsWith( "filename2" ) );
@Test public void testReferencedObjectHasDescription() { BaseStreamStepMeta meta = new StuffStreamMeta(); assertEquals( 1, meta.getReferencedObjectDescriptions().length ); assertTrue( meta.getReferencedObjectDescriptions()[ 0 ] != null ); testRoundTrip( meta ); }
@Test public void testIsReferencedObjectEnabled() { BaseStreamStepMeta meta = new StuffStreamMeta(); assertEquals( 1, meta.isReferencedObjectEnabled().length ); assertFalse( meta.isReferencedObjectEnabled()[ 0 ] ); meta.setTransformationPath( "/some/path" ); assertTrue( meta.isReferencedObjectEnabled()[ 0 ] ); testRoundTrip( meta ); }
Assert.assertTrue( elem.getStringProperty( "One" ).equals( "One" ) ); Assert.assertTrue( elem.getLongProperty( "Two", 0 ) == 2 ); Assert.assertTrue( elem.getBigDecimalProperty( "Three" ).equals( three ) ); Assert.assertTrue( elem.getDateProperty( "Date" ).equals( now ) ); Assert.assertNotNullOrEmpty( elem.getListProperty( "List" ) );
/** * It seems that status and error level are one and alike by design. * Enforce a test on this. In addition achieve code coverage on these. * * @throws Exception */ @Test public void testErrorLevel() throws Exception { final RuntimeContext rctx = (RuntimeContext) runtimeCtx; Assert.assertTrue( rctx.getErrorLevel() == rctx.getStatus() ); }
@Test public void testGetUrlFactory() throws Exception { Assert.assertNotNull( runtimeCtx.getUrlFactory() ); Assert.assertTrue( runtimeCtx.getUrlFactory() == urlFactory ); }
@Test public void testPromptNow() throws Exception { runtimeCtx.setPromptStatus( IRuntimeContext.PROMPT_NO ); Assert.assertFalse( runtimeCtx.isPromptPending() ); runtimeCtx.promptNow(); Assert.assertTrue( runtimeCtx.isPromptPending() ); }
@Test public void testPromptNeeded() throws Exception { runtimeCtx.setPromptStatus( IRuntimeContext.PROMPT_NO ); Assert.assertFalse( runtimeCtx.isPromptPending() ); runtimeCtx.promptNeeded(); Assert.assertTrue( runtimeCtx.isPromptPending() ); }