/** * Constructor. * * @param properties * properties to set. * @throws IllegalArgumentException * if properties is null. */ public PluginPropertyFactory( final KeyValueSet properties ) throws IllegalArgumentException { Assert.assertNotNull( properties, "Properties cannot be null" ); this.properties = properties; }
/** * @param bool * boolean to test. * @throws IllegalArgumentException * if bool is true. */ public static void assertFalse( final boolean bool ) throws IllegalArgumentException { assertFalse( bool, "Value cannot be true" ); }
/** * @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" ); }
/** * Append log on. * * @param dbhost * DB host, e.g localtd * @param user * the user. * @param password * the password. * @return this * @throws IllegalArgumentException * if input is invalid. */ public FastloadControlBuilder logon( final String dbhost, final String user, final String password ) throws IllegalArgumentException { Assert.assertNotBlank( dbhost, "DB host must not be blank" ); Assert.assertNotBlank( user, "User must not be blank" ); Assert.assertNotNull( password, "Password must not be null" ); this.builder.append( "LOGON " ); this.builder.append( dbhost ); this.builder.append( '/' ); this.builder.append( user ); this.builder.append( ',' ); this.builder.append( password ); return this.newline(); }
@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 ); }
Assert.assertNotNull( passThroughKeys ); Assert.assertNotNull( passThroughKeys.get( 0 ) ); Assert.assertTrue( passThroughKeys.get( 0 ).startsWith( "0_file" ) ); Assert.assertTrue( passThroughKeys.get( 0 ).endsWith( "filename1" ) ); Assert.assertNotNull( passThroughKeys.get( 1 ) ); Assert.assertTrue( passThroughKeys.get( 1 ).startsWith( "1_file" ) ); Assert.assertTrue( passThroughKeys.get( 1 ).endsWith( "filename2" ) );
/** * * @param format * the format. * @return this. * @throws IllegalArgumentException * if format is invalid. */ public FastloadControlBuilder setRecordFormat( final String format ) throws IllegalArgumentException { Assert.assertNotBlank( format, "Format must not be blank" ); return line( "SET RECORD " + format ); }
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" ) );
/** * @param value * value to test. * @throws IllegalArgumentException * if value is null or <= 0. */ public static void assertGreaterZero( final Double value ) throws IllegalArgumentException { assertGreaterZero( value, "Value must be greater than 0" ); }
/** * @param lowerKey * key to test. * @throws IllegalArgumentException * if key is invalid. */ public static final void assertKey( final String lowerKey ) throws IllegalArgumentException { Assert.assertNotEmpty( lowerKey, "Key cannot be null or empty" ); if ( !StringUtils.containsOnly( lowerKey, VALID_KEY_CHARS ) ) { throw new IllegalArgumentException( "Key contains invalid characters [validKeyCharacters=" + VALID_KEY_CHARS + "]" ); } if ( lowerKey.charAt( 0 ) == '-' ) { throw new IllegalArgumentException( "Key must not start with '-'" ); } if ( lowerKey.endsWith( "-" ) ) { throw new IllegalArgumentException( "Key must not end with '-'" ); } if ( "_".equals( lowerKey ) ) { throw new IllegalArgumentException( "Key must not be '_'" ); } }
@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 ); }
@Test public void testGetUrlFactory() throws Exception { Assert.assertNotNull( runtimeCtx.getUrlFactory() ); Assert.assertTrue( runtimeCtx.getUrlFactory() == urlFactory ); }
public GoogleAnalyticsApiFacade( HttpTransport httpTransport, JsonFactory jsonFactory, String application, String oathServiceEmail, File keyFile ) throws IOException, GeneralSecurityException { Assert.assertNotNull( httpTransport, "HttpTransport cannot be null" ); Assert.assertNotNull( jsonFactory, "JsonFactory cannot be null" ); Assert.assertNotBlank( application, "Application name cannot be empty" ); Assert.assertNotBlank( oathServiceEmail, "OAuth Service Email name cannot be empty" ); Assert.assertNotNull( keyFile, "OAuth secret key file cannot be null" ); this.httpTransport = httpTransport; Credential credential = new GoogleCredential.Builder() .setTransport( httpTransport ) .setJsonFactory( jsonFactory ) .setServiceAccountScopes( AnalyticsScopes.all() ) .setServiceAccountId( oathServiceEmail ) .setServiceAccountPrivateKeyFromP12File( keyFile ) .build(); analytics = new Analytics.Builder( httpTransport, jsonFactory, credential ) .setApplicationName( application ) .build(); }
/** * Append log on. Connection string must be in form [DBHOST]/[USER],[PASSWORD], e.g. localtd/user,pass; * * @param connectionString * the connection string. * @return this. * @throws IllegalArgumentException * if connection string is blank. */ public FastloadControlBuilder logon( final String connectionString ) throws IllegalArgumentException { Assert.assertNotBlank( connectionString, "Connection must not be blank" ); this.builder.append( "LOGON " ).append( connectionString ); return this.newline(); }
/** * @param value * value to test. * @throws IllegalArgumentException * if value is null or <= 0. */ public static void assertGreaterZero( final Integer value ) throws IllegalArgumentException { assertGreaterZero( value, "Value must be greater than 0" ); }
/** * @param properties * properties to test. * @throws IllegalArgumentException * if properties is null. */ public static void assertProperties( final KeyValueSet properties ) throws IllegalArgumentException { Assert.assertNotNull( properties, "Properties cannot be null" ); }
@Test public void testPromptNow() throws Exception { runtimeCtx.setPromptStatus( IRuntimeContext.PROMPT_NO ); Assert.assertFalse( runtimeCtx.isPromptPending() ); runtimeCtx.promptNow(); Assert.assertTrue( runtimeCtx.isPromptPending() ); }
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 testMatchesExcludePattern() throws Exception { Mockito.when( fileNameMock.getBaseName() ).thenReturn( EXCLUDE_PATTERN_FILE_NAME ); boolean includeFile = fileSelector.includeFile( fileSelectInfoMock ); Assert.assertFalse( includeFile ); }
/** * Factory method. * * @param packageName * package name. * @return messages. * @throws IllegalArgumentException * if package name is blank. */ public static PluginMessages getMessages( final String packageName ) throws IllegalArgumentException { Assert.assertNotBlank( packageName, "Package name cannot be blank" ); PluginMessages pm = MESSAGES_MAP.get( packageName ); if ( pm == null ) { return MESSAGES_MAP.putIfAbsent( packageName, new PluginMessages( packageName ) ); } return pm; }