@Test public void shouldInferCorrectModes() { assertThat( fromRecordState( true, true ), equalTo( Command.Mode.CREATE ) ); assertThat( fromRecordState( false, true ), equalTo( Command.Mode.UPDATE ) ); assertThat( fromRecordState( false, false ), equalTo( Command.Mode.DELETE ) ); assertThat( fromRecordState( true, false ), equalTo( Command.Mode.DELETE ) ); }
break; default: throw new IllegalStateException( command.getMode().name() );
List<Command>[] schemaChangeByMode = new List[Mode.values().length]; for ( int i = 0; i < schemaChangeByMode.length; i++ ) schemaChangeByMode[cmd.getMode().ordinal()].add( cmd ); commands.addAll( schemaChangeByMode[Mode.DELETE.ordinal()] ); commands.addAll( schemaChangeByMode[Mode.CREATE.ordinal()] ); commands.addAll( schemaChangeByMode[Mode.UPDATE.ordinal()] ); assert commands.size() == noOfCommands - skippedCommands : format( "Expected %d final commands, got %d " + "instead, with %d skipped", noOfCommands, commands.size(), skippedCommands );
List<Command>[] schemaChangeByMode = new List[Mode.values().length]; for ( int i = 0; i < schemaChangeByMode.length; i++ ) schemaChangeByMode[cmd.getMode().ordinal()].add( cmd ); commands.addAll( schemaChangeByMode[Mode.DELETE.ordinal()] ); commands.addAll( schemaChangeByMode[Mode.CREATE.ordinal()] ); commands.addAll( schemaChangeByMode[Mode.UPDATE.ordinal()] ); assert commands.size() == noOfCommands - skippedCommands : format( "Expected %d final commands, got %d " + "instead, with %d skipped", noOfCommands, commands.size(), skippedCommands );
break; default: throw new IllegalStateException( command.getMode().name() );
break; default: throw new IllegalStateException( command.getMode().name() );
public BaseCommand( RECORD before, RECORD after ) { setup( after.getId(), Mode.fromRecordState( after ) ); this.before = before; this.after = after; }
public SchemaRuleCommand( SchemaRecord recordsBefore, SchemaRecord recordsAfter, SchemaRule schemaRule ) { setup( Iterables.first( recordsAfter ).getId(), Mode.fromRecordState( Iterables.first( recordsAfter ) ) ); this.recordsBefore = recordsBefore; this.recordsAfter = recordsAfter; this.schemaRule = schemaRule; }
public static Mode fromRecordState( AbstractBaseRecord record ) { return fromRecordState( record.isCreated(), record.inUse() ); } }
break; default: throw new IllegalStateException( command.getMode().name() );
public SchemaRuleCommand( SchemaRecord recordsBefore, SchemaRecord recordsAfter, SchemaRule schemaRule ) { setup( Iterables.first( recordsAfter ).getId(), Mode.fromRecordState( Iterables.first( recordsAfter ) ) ); this.recordsBefore = recordsBefore; this.recordsAfter = recordsAfter; this.schemaRule = schemaRule; }
public static Mode fromRecordState( AbstractBaseRecord record ) { return fromRecordState( record.isCreated(), record.inUse() ); } }
public BaseCommand( RECORD before, RECORD after ) { setup( after.getId(), Mode.fromRecordState( after ) ); this.before = before; this.after = after; }