forked from loafle/openapi-generator-original
Added some Test Cases (#16994)
* New Test Case Added to AndroidClientCodegenTest * New Test Case Added to GenApiControllerTest * New Test Case Added to BirdAndCategoryTest * New Test Case Added to WorkflowSettingsTest * Modified GenApiControllerTest * Added Test case in JavascriptClientCodegenTest * Modified BirdAndCategoryTest * Modified BirdAndCategoryTest --------- Co-authored-by: Mann <mn906219@dal.ca>
This commit is contained in:
@@ -120,4 +120,23 @@ public class WorkflowSettingsTest {
|
|||||||
WorkflowSettings defaults = WorkflowSettings.newBuilder().build();
|
WorkflowSettings defaults = WorkflowSettings.newBuilder().build();
|
||||||
assertOnChangesToDefaults(defaults);
|
assertOnChangesToDefaults(defaults);
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void customOutputDirIsSet() {
|
||||||
|
WorkflowSettings settings = WorkflowSettings.newBuilder()
|
||||||
|
.withOutputDir("custom/output/directory")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(settings.getOutputDir(), Paths.get("custom/output/directory").toAbsolutePath().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void customGlobalPropertiesAreSet() {
|
||||||
|
WorkflowSettings settings = WorkflowSettings.newBuilder()
|
||||||
|
.withGlobalProperty("customKey", "customValue")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Map<String, String> properties = settings.getGlobalProperties();
|
||||||
|
assertEquals(properties.size(), 1, "Global Properties map should allow custom entries");
|
||||||
|
assertEquals(properties.getOrDefault("customKey", ""), "customValue");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -124,5 +124,12 @@ public class GenApiControllerTest {
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(header().string(HttpHeaders.CONTENT_LENGTH, not(0)));
|
.andExpect(header().string(HttpHeaders.CONTENT_LENGTH, not(0)));
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void generateClientWithInvalidOpenAPIUrl() throws Exception {
|
||||||
|
String invalidOpenAPIUrl = "https://test.com:1234/invalid_openapi.json";
|
||||||
|
mockMvc.perform(post("http://test.com:1234/api/gen/clients/java")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.content("{\"openAPIUrl\": \"" + invalidOpenAPIUrl + "\"}"))
|
||||||
|
.andExpect(status().isBadRequest());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,4 +70,23 @@ public class AndroidClientCodegenTest {
|
|||||||
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.iiii.invoker");
|
Assert.assertEquals(codegen.getInvokerPackage(), "xyz.yyyyy.iiii.invoker");
|
||||||
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.iiii.invoker");
|
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.INVOKER_PACKAGE), "xyz.yyyyy.iiii.invoker");
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void testHideGenerationTimestampDisabled() throws Exception {
|
||||||
|
final AndroidClientCodegen codegen = new AndroidClientCodegen();
|
||||||
|
codegen.additionalProperties().put("hideGenerationTimestamp", false);
|
||||||
|
codegen.processOpts();
|
||||||
|
|
||||||
|
Assert.assertEquals(codegen.additionalProperties().get("hideGenerationTimestamp"), Boolean.FALSE);
|
||||||
|
Assert.assertFalse(codegen.isHideGenerationTimestamp());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHideGenerationTimestampEnabled() throws Exception {
|
||||||
|
final AndroidClientCodegen codegen = new AndroidClientCodegen();
|
||||||
|
codegen.additionalProperties().put("hideGenerationTimestamp", true);
|
||||||
|
codegen.processOpts();
|
||||||
|
|
||||||
|
Assert.assertEquals(codegen.additionalProperties().get("hideGenerationTimestamp"), Boolean.TRUE);
|
||||||
|
Assert.assertTrue(codegen.isHideGenerationTimestamp());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,5 +153,17 @@ public class AbstractJavaCodegenExampleValuesTest {
|
|||||||
public String getArtifactVersion() {
|
public String getArtifactVersion() {
|
||||||
return this.artifactVersion;
|
return this.artifactVersion;
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
void customExampleForEnumValue() {
|
||||||
|
final AbstractJavaCodegen fakeJavaCodegen = new P_AbstractJavaCodegen();
|
||||||
|
final CodegenParameter p = new CodegenParameter();
|
||||||
|
p.allowableValues = Collections.singletonMap("values", Arrays.asList("first", "second"));
|
||||||
|
p.dataType = "WrappedEnum";
|
||||||
|
p.example = "CustomEnumValue";
|
||||||
|
|
||||||
|
fakeJavaCodegen.setParameterExampleValue(p);
|
||||||
|
// Custom example value should not be modified
|
||||||
|
Assert.assertEquals(p.example, "CustomEnumValue");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,4 +169,13 @@ public class JavascriptClientCodegenTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(description = "test additional properties for code generation")
|
||||||
|
public void testAdditionalProperties() throws Exception {
|
||||||
|
final JavascriptClientCodegen codegen = new JavascriptClientCodegen();
|
||||||
|
codegen.additionalProperties().put("customProperty", "customValue");
|
||||||
|
codegen.processOpts();
|
||||||
|
|
||||||
|
Assert.assertEquals(codegen.additionalProperties().get("customProperty"), "customValue");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class BirdAndCategoryTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBirdAndCategory() {
|
public void testBirdAndCategory() {
|
||||||
// TODO: test BirdAndCategory
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +42,7 @@ public class BirdAndCategoryTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void sizeTest() {
|
public void sizeTest() {
|
||||||
// TODO: test size
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user