Buggy code:
public class DatasetBasedStreamSizeScheduleStoreTest { public static DatasetBasedStreamSizeScheduleStore scheduleStore ; private static final Namespace NAMESPACE = new co . cask . cdap . proto . Id . Namespace ( Constants . DEFAULT_NAMESPACE ) ; private static final Application APP_ID = new co . cask . cdap . proto . Id . Application ( DatasetBasedStreamSizeScheduleStoreTest . NAMESPACE , "AppWithStreamSizeSchedule" ) ; private static final Program PROGRAM_ID = new co . cask . cdap . proto . Id . Program ( DatasetBasedStreamSizeScheduleStoreTest . APP_ID , ProgramType . WORKFLOW , "SampleWorkflow" ) ; private static final Stream STREAM_ID = Stream . from ( DatasetBasedStreamSizeScheduleStoreTest . NAMESPACE , "stream" ) ; private static final StreamSizeSchedule STREAM_SCHEDULE_1 = new StreamSizeSchedule ( "Schedule1" , "Every<seq2seq4repair_space>1M" , DatasetBasedStreamSizeScheduleStoreTest . STREAM_ID . getName ( ) , 1 ) ; private static final StreamSizeSchedule STREAM_SCHEDULE_2 = new StreamSizeSchedule ( "Schedule2" , "Every<seq2seq4repair_space>10M" , DatasetBasedStreamSizeScheduleStoreTest . STREAM_ID . getName ( ) , 10 ) ; private static final String SCHEDULE_NAME_1 = "Schedule1" ; private static final String SCHEDULE_NAME_2 = "Schedule2" ; private static final SchedulableProgramType PROGRAM_TYPE = SchedulableProgramType . WORKFLOW ; @ BeforeClass public static void set ( ) throws Exception { } @ Test public void testStreamSizeSchedule ( ) throws Exception { DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . persist ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_1 , 0L , 0L , 0L , 0L , true ) ; DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . persist ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 1000L , 10L , 1000L , 10L , false ) ; Assert . assertEquals ( ImmutableList . of ( new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_1 , 0L , 0L , 0L , 0L , true ) , new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 1000L , 10L , 1000L , 10L , false ) ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . suspend ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_1 ) ; Assert . assertEquals ( ImmutableList . of ( new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_1 , 0L , 0L , 0L , 0L , false ) , new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 1000L , 10L , 1000L , 10L , false ) ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . resume ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_2 ) ; Assert . assertEquals ( ImmutableList . of ( new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_1 , 0L , 0L , 0L , 0L , false ) , new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 1000L , 10L , 1000L , 10L , true ) ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . updateBaseRun ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_2 , 10000L , 100L ) ; Assert . assertEquals ( ImmutableList . of ( new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_1 , 0L , 0L , 0L , 0L , false ) , new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 10000L , 100L , 1000L , 10L , true ) ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; <START_BUG> DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . updateLastRun ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_1 , 100L , 10000L ) ; <END_BUG> Assert . assertEquals ( ImmutableList . of ( new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_1 , 0L , 0L , 100L , 10000L , false ) , new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 10000L , 100L , 1000L , 10L , true ) ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . updateSchedule ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_1 , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 ) ; Assert . assertEquals ( ImmutableList . of ( new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 0L , 0L , 100L , 10000L , false ) , new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 10000L , 100L , 1000L , 10L , true ) ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . delete ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_1 ) ; Assert . assertEquals ( ImmutableList . of ( new StreamSizeScheduleState ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . STREAM_SCHEDULE_2 , 10000L , 100L , 1000L , 10L , true ) ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . delete ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_2 ) ; Assert . assertEquals ( ImmutableList . < StreamSizeScheduleState > of ( ) , DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . list ( ) ) ; } }

Fix:
DatasetBasedStreamSizeScheduleStoreTest . scheduleStore . updateLastRun ( DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_ID , DatasetBasedStreamSizeScheduleStoreTest . PROGRAM_TYPE , DatasetBasedStreamSizeScheduleStoreTest . SCHEDULE_NAME_1 , 100L , 10000L , null ) ;