Skip to content
Open
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 @@ -47,7 +47,7 @@ public record JobParameter<T>(String name, T value, Class<T> type, boolean ident
* @since 6.0
*/
public JobParameter {
Assert.notNull(value, "name must not be null");
Assert.notNull(name, "name must not be null");
Assert.notNull(value, "value must not be null");
Assert.notNull(type, "type must not be null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,42 @@
*/
package org.springframework.batch.core;

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

import java.util.Date;

import org.junit.jupiter.api.Test;

import org.springframework.batch.core.job.parameters.JobParameter;

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

/**
* @author Lucas Ward
* @author Mahmoud Ben Hassine
*
*/
class JobParameterTests {

@Test
void testConstructorNameNotNull() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> new JobParameter<>(null, "test", String.class, true));
assertEquals("name must not be null", exception.getMessage());
}

@Test
void testConstructorValueNotNull() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> new JobParameter<>("param", null, String.class, true));
assertEquals("value must not be null", exception.getMessage());
}

@Test
void testConstructorTypeNotNull() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> new JobParameter<>("param", "test", null, true));
assertEquals("type must not be null", exception.getMessage());
}

@Test
void testStringParameter() {
JobParameter<String> jobParameter = new JobParameter<>("param", "test", String.class, true);
Expand Down