Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void cachableCommandsShouldBeIterableWithStillOpenIterator() {

builder.getCachableCommands().shutdown(KILL);
assertTrue(iterator.hasNext());
assertThat(iterator.next(), is(new Command(SHUTDOWN, "KILL")));
assertThat(iterator.next(), is(new Command(SHUTDOWN, KILL.getParam())));

builder.removeStream(is);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public int read() throws IOException {
Command bye = decoder.decode();
assertThat(bye, is(notNullValue()));
assertThat(bye.getCommandType(), is(SHUTDOWN));
assertThat(bye.getData(), is(KILL.name()));
assertThat(bye.getData(), is(KILL.getParam()));
Command noop = decoder.decode();
assertThat(noop, is(notNullValue()));
assertThat(noop.getCommandType(), is(NOOP));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Command(MasterProcessCommand command) {
}

public static Command toShutdown(Shutdown shutdownType) {
return new Command(MasterProcessCommand.SHUTDOWN, shutdownType.name());
return new Command(MasterProcessCommand.SHUTDOWN, shutdownType.getParam());
}

public static Command toRunClass(String runClass) {
Expand All @@ -65,13 +65,12 @@ public String getData() {

/**
* @return {@link Shutdown} or {@link Shutdown#DEFAULT} if {@link #getData()} is null or blank string
* @throws IllegalArgumentException if string data {@link #getData()} is not applicable to enum {@link Shutdown}
*/
public Shutdown toShutdownData() {
if (command != MasterProcessCommand.SHUTDOWN) {
throw new IllegalStateException("expected MasterProcessCommand.SHUTDOWN");
}
return isBlank(data) ? Shutdown.DEFAULT : Shutdown.valueOf(data);
return isBlank(data) ? Shutdown.DEFAULT : Shutdown.parameterOf(data);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void testDecoderShutdownWithExit() throws IOException {
CommandChannelDecoder decoder = new CommandChannelDecoder(newChannel(is), args);
Command command = decoder.decode();
assertThat(command.getCommandType()).isSameAs(SHUTDOWN);
assertThat(command.getData()).isEqualTo(shutdownType.name());
assertThat(command.getData()).isEqualTo(shutdownType.getParam());
}

@Test
Expand All @@ -159,7 +159,7 @@ public void testDecoderShutdownWithKill() throws IOException {
CommandChannelDecoder decoder = new CommandChannelDecoder(newChannel(is), args);
Command command = decoder.decode();
assertThat(command.getCommandType()).isSameAs(SHUTDOWN);
assertThat(command.getData()).isEqualTo(shutdownType.name());
assertThat(command.getData()).isEqualTo(shutdownType.getParam());
}

@Test
Expand All @@ -174,7 +174,7 @@ public void testDecoderShutdownWithDefault() throws IOException {
CommandChannelDecoder decoder = new CommandChannelDecoder(newChannel(is), args);
Command command = decoder.decode();
assertThat(command.getCommandType()).isSameAs(SHUTDOWN);
assertThat(command.getData()).isEqualTo(shutdownType.name());
assertThat(command.getData()).isEqualTo(shutdownType.getParam());
}

@Test
Expand Down