Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isNonDefaultExitStatus in test #4690

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -15,14 +15,16 @@
*/
package org.springframework.batch.core;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.util.SerializationUtils;

import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.*;

/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
Expand Down Expand Up @@ -186,4 +188,38 @@ void testSerializable() {
assertEquals(status.getExitCode(), clone.getExitCode());
}

@ParameterizedTest
@MethodSource("provideKnownExitStatuses")
public void testIsNonDefaultExitStatusShouldReturnTrue(ExitStatus status) {
boolean result = ExitStatus.isNonDefaultExitStatus(status);
assertTrue(result);
}

@ParameterizedTest
@MethodSource("provideCustomExitStatuses")
public void testIsNonDefaultExitStatusShouldReturnFalse(ExitStatus status) {
boolean result = ExitStatus.isNonDefaultExitStatus(status);
assertFalse(result);
}

private static Stream<Arguments> provideKnownExitStatuses() {
return Stream.of(
Arguments.of((ExitStatus) null),
Arguments.of(new ExitStatus(null)),
Arguments.of(ExitStatus.COMPLETED),
Arguments.of(ExitStatus.EXECUTING),
Arguments.of(ExitStatus.FAILED),
Arguments.of(ExitStatus.NOOP),
Arguments.of(ExitStatus.STOPPED),
Arguments.of(ExitStatus.UNKNOWN)
);
}

private static Stream<Arguments> provideCustomExitStatuses() {
return Stream.of(
Arguments.of(new ExitStatus("CUSTOM")),
Arguments.of(new ExitStatus("SUCCESS")),
Arguments.of(new ExitStatus("DONE"))
);
}
}