committed by
Mahmoud Ben Hassine
parent
597ecb4b68
commit
145c31b86f
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -23,7 +23,7 @@ import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -58,7 +58,7 @@ public class JobParameters implements Serializable {
|
||||
* Default constructor.
|
||||
*/
|
||||
public JobParameters() {
|
||||
this.parameters = new LinkedHashMap<>();
|
||||
this.parameters = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +68,7 @@ public class JobParameters implements Serializable {
|
||||
* {@link JobParameter} value.
|
||||
*/
|
||||
public JobParameters(Map<String, JobParameter<?>> parameters) {
|
||||
this.parameters = new LinkedHashMap<>(parameters);
|
||||
this.parameters = new HashMap<>(parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 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.
|
||||
@@ -21,9 +21,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.lang.NonNull;
|
||||
@@ -57,7 +55,7 @@ public class JobParametersBuilder {
|
||||
* Default constructor. Initializes the builder with empty parameters.
|
||||
*/
|
||||
public JobParametersBuilder() {
|
||||
this.parameterMap = new LinkedHashMap<>();
|
||||
this.parameterMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +64,7 @@ public class JobParametersBuilder {
|
||||
*/
|
||||
public JobParametersBuilder(JobExplorer jobExplorer) {
|
||||
this.jobExplorer = jobExplorer;
|
||||
this.parameterMap = new LinkedHashMap<>();
|
||||
this.parameterMap = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +83,7 @@ public class JobParametersBuilder {
|
||||
*/
|
||||
public JobParametersBuilder(JobParameters jobParameters, JobExplorer jobExplorer) {
|
||||
this.jobExplorer = jobExplorer;
|
||||
this.parameterMap = new LinkedHashMap<>(jobParameters.getParameters());
|
||||
this.parameterMap = new HashMap<>(jobParameters.getParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2022 the original author or authors.
|
||||
* Copyright 2008-2023 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.
|
||||
@@ -20,7 +20,7 @@ import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -29,6 +29,7 @@ import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.job.SimpleJob;
|
||||
import org.springframework.batch.core.launch.support.RunIdIncrementer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -121,31 +122,27 @@ class JobParametersBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOrderedTypes() {
|
||||
void testNotOrderedTypes() {
|
||||
this.parametersBuilder.addDate("SCHEDULE_DATE", date);
|
||||
this.parametersBuilder.addLong("LONG", 1L);
|
||||
this.parametersBuilder.addString("STRING", "string value");
|
||||
Iterator<String> parameters = this.parametersBuilder.toJobParameters().getParameters().keySet().iterator();
|
||||
assertEquals("SCHEDULE_DATE", parameters.next());
|
||||
assertEquals("LONG", parameters.next());
|
||||
assertEquals("STRING", parameters.next());
|
||||
Set<String> parameters = this.parametersBuilder.toJobParameters().getParameters().keySet();
|
||||
assertThat(parameters).containsExactlyInAnyOrder("STRING", "LONG", "SCHEDULE_DATE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOrderedStrings() {
|
||||
void testNotOrderedStrings() {
|
||||
this.parametersBuilder.addString("foo", "value foo");
|
||||
this.parametersBuilder.addString("bar", "value bar");
|
||||
this.parametersBuilder.addString("spam", "value spam");
|
||||
Iterator<String> parameters = this.parametersBuilder.toJobParameters().getParameters().keySet().iterator();
|
||||
assertEquals("foo", parameters.next());
|
||||
assertEquals("bar", parameters.next());
|
||||
assertEquals("spam", parameters.next());
|
||||
Set<String> parameters = this.parametersBuilder.toJobParameters().getParameters().keySet();
|
||||
assertThat(parameters).containsExactlyInAnyOrder("foo", "bar", "spam");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddJobParameter() {
|
||||
JobParameter jobParameter = new JobParameter("bar", String.class);
|
||||
this.parametersBuilder.addParameter("foo", jobParameter);
|
||||
this.parametersBuilder.addJobParameter("foo", jobParameter);
|
||||
Map<String, JobParameter<?>> parameters = this.parametersBuilder.toJobParameters().getParameters();
|
||||
assertEquals(1, parameters.size());
|
||||
assertEquals("bar", parameters.get("foo").getValue());
|
||||
|
||||
Reference in New Issue
Block a user