Code commit for BAEL-4992 (#10952)
* code commit for BAEL-4992 * tab/space change for pom.xml
This commit is contained in:
committed by
GitHub
parent
ac45b9fb6c
commit
045ba9ee4f
@@ -0,0 +1,38 @@
|
||||
package com.baeldung.jsontojavaclass;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class JsonToJavaClassConversionUnitTest {
|
||||
|
||||
private JsonToJavaClassConversion jsonToJavaConversion = new JsonToJavaClassConversion();
|
||||
|
||||
@Test
|
||||
void whenProvideInputJSON_thenGenerateJavaClass() throws MalformedURLException, IOException {
|
||||
|
||||
String packageName = "com.baeldung.jsontojavaclass.pojo";
|
||||
|
||||
// load input JSON file
|
||||
String jsonPath = "src/test/resources/";
|
||||
File inputJson = new File(jsonPath + "sample_input.json");
|
||||
|
||||
// create the local directory for generating the Java Class file
|
||||
String outputPath = "src/main/java/";
|
||||
File outputJavaClassDirectory = new File(outputPath);
|
||||
outputJavaClassDirectory.mkdirs();
|
||||
|
||||
String className = "SamplePojo";
|
||||
|
||||
Object object = jsonToJavaConversion.convertJsonToJavaClass(inputJson.toURI()
|
||||
.toURL(), outputJavaClassDirectory, packageName, className);
|
||||
System.out.println(object);
|
||||
|
||||
Assertions.assertNotNull(object);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user