-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main-3' into corneil/main3-junit5
# Conflicts: # spring-cloud-dataflow-rest-client/src/test/java/org/springframework/cloud/dataflow/rest/client/DataflowTemplateTests.java # spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/JobExecutionControllerTests.java # spring-cloud-dataflow-shell-core/src/test/java/org/springframework/cloud/dataflow/shell/command/JobCommandTests.java
- Loading branch information
Showing
24 changed files
with
380 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ngframework/cloud/dataflow/rest/support/jackson/JobParameterJacksonDeserializerTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2024 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.dataflow.rest.support.jackson; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonFactory; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.json.UTF8StreamJsonParser; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.batch.core.JobParameter; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; | ||
|
||
public class JobParameterJacksonDeserializerTests { | ||
|
||
@Test | ||
public void validJobParameter() throws IOException { | ||
JobParameterJacksonDeserializer jobParameterJacksonDeserializer = new JobParameterJacksonDeserializer(); | ||
String json = "{\"value\":\"BAR\",\"type\":\"java.lang.String\",\"identifying\":true}"; | ||
JobParameter jobParameter = jobParameterJacksonDeserializer.deserialize(getJsonParser(json), null); | ||
assertThat(jobParameter.getType()).isEqualTo(String.class); | ||
assertThat(jobParameter.getValue()).isEqualTo("BAR"); | ||
assertThat(jobParameter.isIdentifying()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void inValidJobParameter() throws IOException { | ||
JobParameterJacksonDeserializer jobParameterJacksonDeserializer = new JobParameterJacksonDeserializer(); | ||
String json = "{\"value\":\"BAR\",\"type\":\"java.lang.FOO\",\"identifying\":true}"; | ||
assertThatExceptionOfType(IllegalArgumentException.class) | ||
.isThrownBy(() -> { | ||
jobParameterJacksonDeserializer.deserialize(getJsonParser(json), null); | ||
}) | ||
.withMessage("JobParameter type java.lang.FOO is not supported by DataFlow"); | ||
} | ||
|
||
private JsonParser getJsonParser(String json) throws IOException { | ||
JsonFactory factory = new JsonFactory(); | ||
byte[] jsonData = json.getBytes(); | ||
ByteArrayInputStream inputStream = new ByteArrayInputStream(jsonData); | ||
UTF8StreamJsonParser jsonParser = (UTF8StreamJsonParser) factory.createParser(inputStream); | ||
jsonParser.setCodec(new ObjectMapper()); | ||
return jsonParser; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.