Use type-safe constants in ExitStatus#isRunning
Signed-off-by: sjiwon <sjiwon4491@gmail.com>
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
b9b08bfb22
commit
30b5120c93
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2023 the original author or authors.
|
||||
* Copyright 2006-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import java.io.StringWriter;
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author JiWon Seo
|
||||
*
|
||||
*/
|
||||
public class ExitStatus implements Serializable, Comparable<ExitStatus> {
|
||||
@@ -231,7 +232,7 @@ public class ExitStatus implements Serializable, Comparable<ExitStatus> {
|
||||
* @return {@code true} if the exit code is {@code EXECUTING} or {@code UNKNOWN}.
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
return "EXECUTING".equals(this.exitCode) || "UNKNOWN".equals(this.exitCode);
|
||||
return EXECUTING.exitCode.equals(this.exitCode) || UNKNOWN.exitCode.equals(this.exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2024 the original author or authors.
|
||||
* Copyright 2006-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author JiWon Seo
|
||||
*
|
||||
*/
|
||||
class ExitStatusTests {
|
||||
@@ -153,7 +154,7 @@ class ExitStatusTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddExitDescriptionWIthStacktrace() {
|
||||
void testAddExitDescriptionWithStacktrace() {
|
||||
ExitStatus status = ExitStatus.EXECUTING.addExitDescription(new RuntimeException("Foo"));
|
||||
assertNotSame(ExitStatus.EXECUTING, status);
|
||||
String description = status.getExitDescription();
|
||||
@@ -182,8 +183,15 @@ class ExitStatusTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnknownIsRunning() {
|
||||
void testIsRunning() {
|
||||
// running statuses
|
||||
assertTrue(ExitStatus.EXECUTING.isRunning());
|
||||
assertTrue(ExitStatus.UNKNOWN.isRunning());
|
||||
// non running statuses
|
||||
assertFalse(ExitStatus.COMPLETED.isRunning());
|
||||
assertFalse(ExitStatus.FAILED.isRunning());
|
||||
assertFalse(ExitStatus.STOPPED.isRunning());
|
||||
assertFalse(ExitStatus.NOOP.isRunning());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user