|
46 | 46 | import java.util.Arrays; |
47 | 47 | import java.util.List; |
48 | 48 | import java.util.Map; |
49 | | -import java.util.HashMap; |
50 | 49 |
|
51 | 50 |
|
52 | 51 | import static org.openapitools.codegen.TestUtils.createCodegenModelWrapper; |
@@ -102,38 +101,23 @@ private void assertFileEquals(Path generatedFilePath, Path expectedFilePath) thr |
102 | 101 | public void testCodeGenWithPrimitiveOneOf() throws IOException { |
103 | 102 | // set line break to \n across all platforms |
104 | 103 | System.setProperty("line.separator", "\n"); |
105 | | - Map<String, String> importmapping = new HashMap<>(); |
106 | | - Map<String, String> typemapping = new HashMap<>(); |
107 | | - typemapping.put("AnyType", "ObjectMap"); |
108 | | - typemapping.put("object", "ObjectMap"); |
109 | | - typemapping.put("bytes", "bytes"); |
110 | | - typemapping.put("NullValue", "NullValue"); |
111 | | - typemapping.put("number", "GeneralNumber"); |
| 104 | + |
112 | 105 | File output = Files.createTempDirectory("test").toFile(); |
113 | | - Map<String, Object> additionalProperties = new HashMap<>(); |
114 | | - additionalProperties.put("numberedFieldNumberList", true); |
115 | | - additionalProperties.put("aggregateModelsName", "aaaa"); |
116 | | - additionalProperties.put("supportMultipleResponses", false); |
117 | | - Map<String, String> inline = new HashMap<>(); |
118 | | - Map<String, String> globalProperty = new HashMap<>(); |
119 | | - globalProperty.put("skipFormModel", "true"); |
120 | | - inline.put("RESOLVE_INLINE_ENUMS", "true"); |
121 | | - inline.put("SKIP_SCHEMA_REUSE", "true"); |
| 106 | + |
122 | 107 | final CodegenConfigurator configurator = new CodegenConfigurator() |
123 | 108 | .setGeneratorName("protobuf-schema") |
124 | 109 | .setInputSpec("src/test/resources/3_0/oneOf.yaml") |
125 | | - .setAdditionalProperties(additionalProperties) |
126 | | - .setTypeMappings(typemapping) |
127 | | - .setImportMappings(importmapping) |
128 | | - .setGlobalProperties(globalProperty) |
129 | | - .setInlineSchemaOptions(inline) |
130 | | - .setValidateSpec(false) |
131 | | - .setOutputDir("/home/user/openapi-generator/test/"); |
| 110 | + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); |
132 | 111 |
|
133 | 112 | final ClientOptInput clientOptInput = configurator.toClientOptInput(); |
134 | 113 | DefaultGenerator generator = new DefaultGenerator(); |
135 | 114 | List<File> files = generator.opts(clientOptInput).generate(); |
136 | 115 |
|
| 116 | + TestUtils.ensureContainsFile(files, output, "models/fruit.proto"); |
| 117 | + Path path = Paths.get(output + "/models/fruit.proto"); |
| 118 | + |
| 119 | + assertFileEquals(path, Paths.get("src/test/resources/3_0/protobuf-schema/fruitOneOf.proto")); |
| 120 | + |
137 | 121 | output.deleteOnExit(); |
138 | 122 | } |
139 | 123 |
|
|
0 commit comments