Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bin/utils/test_file_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
sha256: 24c6a39a9d7327d397dc038c368a19c84f14ed96a69fe28d53719b3eaf0a725c
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/api/PetApiTest.java"
sha256: 5e9f471d34310f94895751bb96cc79583376f043593c3a387c82077c70f8102f
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/MammalTest.java"
sha256: 67a9e63e13ebddac21cb236aa015edce30f5d3bd8d6adcf50044cad00d48c45e
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/model/ZebraTest.java"
sha256: 15eeb6d8a9a79d0f1930b861540d9c5780d6c49ea4fdb68269ac3e7ec481e142
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/MammalTest.java"
sha256: a09c120b694788b12f8d73cc0dd307e509ee1744b2ff45c5711b1186c419f915
- filename: "samples/client/petstore/java/jersey3/src/test/java/org/openapitools/client/ZebraTest.java"
sha256: 15e509d8cb8e9b050c6418cfbf8a5dced9acc97cf29e5727da9f907c52d11f1e
- filename: "samples/client/petstore/java/okhttp-gson-3.1/src/test/java/org/openapitools/client/api/PetApiTest.java"
sha256: d8f7fff724f81e666daf115cc25f8347e1fda4e861aa30df0dae3fa50c91404c
- filename: "samples/client/petstore/java/okhttp-gson-dynamicOperations/src/test/java/org/openapitools/client/api/PetApiTest.java"
Expand Down
9 changes: 0 additions & 9 deletions samples/client/petstore/java/jersey2-java8/docs/AnimalFarm.md

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions samples/client/petstore/java/jersey3/docs/InlineObject.md

This file was deleted.

13 changes: 0 additions & 13 deletions samples/client/petstore/java/jersey3/docs/InlineObject1.md

This file was deleted.

32 changes: 0 additions & 32 deletions samples/client/petstore/java/jersey3/docs/InlineObject2.md

This file was deleted.

25 changes: 0 additions & 25 deletions samples/client/petstore/java/jersey3/docs/InlineObject3.md

This file was deleted.

13 changes: 0 additions & 13 deletions samples/client/petstore/java/jersey3/docs/InlineObject4.md

This file was deleted.

13 changes: 0 additions & 13 deletions samples/client/petstore/java/jersey3/docs/InlineObject5.md

This file was deleted.

13 changes: 0 additions & 13 deletions samples/client/petstore/java/jersey3/docs/InlineResponseDefault.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package org.openapitools.client;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.client.JSON;
import org.openapitools.client.model.*;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
* Model tests for Mammal
*/
public class MammalTest {
private final Mammal model = new Mammal();

/**
* Model tests for Mammal
*/
@Test
public void testMammal() throws Exception {
Mammal m = new Mammal();
Zebra z = new Zebra();
z.setType(Zebra.TypeEnum.MOUNTAIN);
z.setClassName("zebra");
m.setActualInstance(z);
Assertions.assertEquals(JSON.getDefault().getMapper().writeValueAsString(m), "{\"type\":\"mountain\",\"className\":\"zebra\"}");
}

/**
* Model tests for getActualInstanceRecursively
*/
@Test
public void testGetActualInstanceRecursively() throws Exception {
Mammal m = new Mammal();
Pig p = new Pig();
DanishPig dp = new DanishPig();
dp.setClassName("danish_pig");
p.setActualInstance(dp);
m.setActualInstance(p);
Assertions.assertTrue(m.getActualInstanceRecursively() instanceof DanishPig);

Pig p2 = new Pig();
m.setActualInstance(p2);
Assertions.assertEquals(m.getActualInstanceRecursively(), null);
}

/**
* Test the property 'hasBaleen'
*/
@Test
public void hasBaleenTest() {
// TODO: test hasBaleen
}

/**
* Test the property 'hasTeeth'
*/
@Test
public void hasTeethTest() {
// TODO: test hasTeeth
}

/**
* Test the property 'className'
*/
@Test
public void classNameTest() {
// TODO: test className
}

/**
* Test the property 'type'
*/
@Test
public void typeTest() {
// TODO: test type
}

/**
* Test code sample
*/
@Test
public void codeSampleTest() {
Mammal exampleMammal = new Mammal();

// create a new Pig
Pig examplePig = new Pig();
// set Mammal to Pig
exampleMammal.setActualInstance(examplePig);
// to get back the Pig set earlier
Pig testPig = (Pig) exampleMammal.getActualInstance();

// create a new Whale
Whale exampleWhale = new Whale();
// set Mammal to Whale
exampleMammal.setActualInstance(exampleWhale);
// to get back the Whale set earlier
Whale testWhale = (Whale) exampleMammal.getActualInstance();

// create a new Zebra
Zebra exampleZebra = new Zebra();
// set Mammal to Zebra
exampleMammal.setActualInstance(exampleZebra);
// to get back the Zebra set earlier
Zebra testZebra = (Zebra) exampleMammal.getActualInstance();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package org.openapitools.client;

import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

import org.openapitools.client.JSON;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openapitools.client.model.Zebra;

/**
* Model tests for Zebra
*/
public class ZebraTest {
private final Zebra model = new Zebra();

/**
* Model tests for Zebra
*/
@Test
public void testZebra() {
Zebra z = new Zebra();
z.setClassName("zebra");
Map<String, String> m = new HashMap<>();
z.putAdditionalProperty("key1", "value1");
z.putAdditionalProperty("key2", 12321);
z.setType(Zebra.TypeEnum.MOUNTAIN);

JSON j = new JSON();
try {
// serialize
Assertions.assertEquals(j.getMapper().writeValueAsString(z), "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}");

// deserialize
String zebraJson = "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}";
Zebra zebraFromJson = j.getMapper().readValue(zebraJson, Zebra.class);
Assertions.assertEquals(zebraFromJson.getType(), Zebra.TypeEnum.MOUNTAIN);
Assertions.assertEquals(zebraFromJson.getClassName(), "zebra");
Assertions.assertEquals(zebraFromJson.getAdditionalProperties().size(), 2);
Assertions.assertEquals(zebraFromJson.getAdditionalProperty("key1"), "value1");
Assertions.assertEquals(zebraFromJson.getAdditionalProperty("key2"), 12321);
} catch (Exception ex) {
Assertions.assertEquals(true, false); // exception shouldn't be thrown
}
}

/**
* Test the property 'type'
*/
@Test
public void typeTest() {
String zebraJson = "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}";

JSON j = new JSON();
TypeFactory typeFactory = j.getMapper().getTypeFactory();
MapType mapType = typeFactory.constructMapType(HashMap.class, String.class, Object.class);
try {
HashMap<String, Object> map = j.getMapper().readValue(zebraJson, mapType);
Assertions.assertEquals(map.get("type"), "mountain");

Map<String,Object> result =
j.getMapper().readValue(zebraJson, new TypeReference<Map<String,Object>>() {});

Assertions.assertEquals(result.get("type"), "mountain");
} catch (Exception ex) {
Assertions.assertEquals(true, false); // exception shouldn't be thrown
}
}

/**
* Test the property 'className'
*/
@Test
public void classNameTest() {
// TODO: test className
}

}
Loading
Loading