@Test(expected = NullPointerException.class) public void testNullPartitionKey() { ManagedJobProcessor jobProcessor = new ManagedJobProcessor(); jobProcessor.hiveHqlGenerator = Mockito.mock(HiveHqlGenerator.class); ProcessBuilder pb = jobProcessor.createProcessBuilder(new JobDefinition(1L, "test", "obj", "usage", "ft", "2016-08-12", "null", "111", null)); }
@Override public ProcessBuilder createProcessBuilder( JobDefinition od ) { Objects.requireNonNull( od.getPartitionKey(), "PartitionKey is null" ); List<String> partitionVal = Lists.newArrayList(); String partitionValue = od.getPartitionValue(); if ( partitionValue.contains( JobProcessorConstants.DOUBLE_UNDERSCORE ) ) { try { String[] parts = partitionValue.split( JobProcessorConstants.DOUBLE_UNDERSCORE ); String startDate = parts[1]; String endDate = parts[0]; SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" ); Date start = format.parse( startDate ); Date end = format.parse( endDate ); Date d = start; while ( d.before( end ) ) { partitionVal.add( format.format( d ) ); d.setTime( d.getTime() + 24 * 3600 * 1000 ); } partitionVal.add( endDate ); } catch ( ParseException e ) { logger.severe( e.getMessage() ); return null; } } else if ( partitionValue.contains( JobProcessorConstants.COMMA ) ) { partitionVal.addAll( Lists.newArrayList( partitionValue.split( JobProcessorConstants.COMMA ) ) ); } else { partitionVal.add( partitionValue ); } try { String path = hiveHqlGenerator.buildHql( od, partitionVal ); ProcessBuilder pb = new ProcessBuilder( "hive", "-v", "-f", path ); return pb; } catch ( Throwable ex ) { errorBuffer.append( ex.getMessage() ); ex.printStackTrace(); } return null; }
ManagedJobProcessor extends JobProcessor { @Override public ProcessBuilder createProcessBuilder( JobDefinition od ) { Objects.requireNonNull( od.getPartitionKey(), "PartitionKey is null" ); List<String> partitionVal = Lists.newArrayList(); String partitionValue = od.getPartitionValue(); if ( partitionValue.contains( JobProcessorConstants.DOUBLE_UNDERSCORE ) ) { try { String[] parts = partitionValue.split( JobProcessorConstants.DOUBLE_UNDERSCORE ); String startDate = parts[1]; String endDate = parts[0]; SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" ); Date start = format.parse( startDate ); Date end = format.parse( endDate ); Date d = start; while ( d.before( end ) ) { partitionVal.add( format.format( d ) ); d.setTime( d.getTime() + 24 * 3600 * 1000 ); } partitionVal.add( endDate ); } catch ( ParseException e ) { logger.severe( e.getMessage() ); return null; } } else if ( partitionValue.contains( JobProcessorConstants.COMMA ) ) { partitionVal.addAll( Lists.newArrayList( partitionValue.split( JobProcessorConstants.COMMA ) ) ); } else { partitionVal.add( partitionValue ); } try { String path = hiveHqlGenerator.buildHql( od, partitionVal ); ProcessBuilder pb = new ProcessBuilder( "hive", "-v", "-f", path ); return pb; } catch ( Throwable ex ) { errorBuffer.append( ex.getMessage() ); ex.printStackTrace(); } return null; } }
ManagedJobProcessor extends JobProcessor { @Override public ProcessBuilder createProcessBuilder( JobDefinition od ) { Objects.requireNonNull( od.getPartitionKey(), "PartitionKey is null" ); List<String> partitionVal = Lists.newArrayList(); String partitionValue = od.getPartitionValue(); if ( partitionValue.contains( JobProcessorConstants.DOUBLE_UNDERSCORE ) ) { try { String[] parts = partitionValue.split( JobProcessorConstants.DOUBLE_UNDERSCORE ); String startDate = parts[1]; String endDate = parts[0]; SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" ); Date start = format.parse( startDate ); Date end = format.parse( endDate ); Date d = start; while ( d.before( end ) ) { partitionVal.add( format.format( d ) ); d.setTime( d.getTime() + 24 * 3600 * 1000 ); } partitionVal.add( endDate ); } catch ( ParseException e ) { logger.severe( e.getMessage() ); return null; } } else if ( partitionValue.contains( JobProcessorConstants.COMMA ) ) { partitionVal.addAll( Lists.newArrayList( partitionValue.split( JobProcessorConstants.COMMA ) ) ); } else { partitionVal.add( partitionValue ); } try { String path = hiveHqlGenerator.buildHql( od, partitionVal ); ProcessBuilder pb = new ProcessBuilder( "hive", "-v", "-f", path ); return pb; } catch ( Throwable ex ) { errorBuffer.append( ex.getMessage() ); ex.printStackTrace(); } return null; }  }
ManagedJobProcessor extends JobProcessor { @Override public ProcessBuilder createProcessBuilder( JobDefinition od ) { Objects.requireNonNull( od.getPartitionKey(), "PartitionKey is null" ); List<String> partitionVal = Lists.newArrayList(); String partitionValue = od.getPartitionValue(); if ( partitionValue.contains( JobProcessorConstants.DOUBLE_UNDERSCORE ) ) { try { String[] parts = partitionValue.split( JobProcessorConstants.DOUBLE_UNDERSCORE ); String startDate = parts[1]; String endDate = parts[0]; SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" ); Date start = format.parse( startDate ); Date end = format.parse( endDate ); Date d = start; while ( d.before( end ) ) { partitionVal.add( format.format( d ) ); d.setTime( d.getTime() + 24 * 3600 * 1000 ); } partitionVal.add( endDate ); } catch ( ParseException e ) { logger.severe( e.getMessage() ); return null; } } else if ( partitionValue.contains( JobProcessorConstants.COMMA ) ) { partitionVal.addAll( Lists.newArrayList( partitionValue.split( JobProcessorConstants.COMMA ) ) ); } else { partitionVal.add( partitionValue ); } try { String path = hiveHqlGenerator.buildHql( od, partitionVal ); ProcessBuilder pb = new ProcessBuilder( "hive", "-v", "-f", path ); return pb; } catch ( Throwable ex ) { errorBuffer.append( ex.getMessage() ); ex.printStackTrace(); } return null; }  @Override ProcessBuilder createProcessBuilder( JobDefinition od ); }
ManagedJobProcessor extends JobProcessor { @Override public ProcessBuilder createProcessBuilder( JobDefinition od ) { Objects.requireNonNull( od.getPartitionKey(), "PartitionKey is null" ); List<String> partitionVal = Lists.newArrayList(); String partitionValue = od.getPartitionValue(); if ( partitionValue.contains( JobProcessorConstants.DOUBLE_UNDERSCORE ) ) { try { String[] parts = partitionValue.split( JobProcessorConstants.DOUBLE_UNDERSCORE ); String startDate = parts[1]; String endDate = parts[0]; SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" ); Date start = format.parse( startDate ); Date end = format.parse( endDate ); Date d = start; while ( d.before( end ) ) { partitionVal.add( format.format( d ) ); d.setTime( d.getTime() + 24 * 3600 * 1000 ); } partitionVal.add( endDate ); } catch ( ParseException e ) { logger.severe( e.getMessage() ); return null; } } else if ( partitionValue.contains( JobProcessorConstants.COMMA ) ) { partitionVal.addAll( Lists.newArrayList( partitionValue.split( JobProcessorConstants.COMMA ) ) ); } else { partitionVal.add( partitionValue ); } try { String path = hiveHqlGenerator.buildHql( od, partitionVal ); ProcessBuilder pb = new ProcessBuilder( "hive", "-v", "-f", path ); return pb; } catch ( Throwable ex ) { errorBuffer.append( ex.getMessage() ); ex.printStackTrace(); } return null; }  @Override ProcessBuilder createProcessBuilder( JobDefinition od );  }