Skip to content

Commit 27d8e7d

Browse files
committed
clean up java jersey3 smaples
1 parent 28e2254 commit 27d8e7d

File tree

11 files changed

+238
-224
lines changed

11 files changed

+238
-224
lines changed

samples/client/petstore/java/jersey3/docs/InlineObject.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

samples/client/petstore/java/jersey3/docs/InlineObject1.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

samples/client/petstore/java/jersey3/docs/InlineObject2.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

samples/client/petstore/java/jersey3/docs/InlineObject3.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

samples/client/petstore/java/jersey3/docs/InlineObject4.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

samples/client/petstore/java/jersey3/docs/InlineObject5.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

samples/client/petstore/java/jersey3/docs/InlineResponseDefault.md

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
* OpenAPI Petstore
3+
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package org.openapitools.client;
15+
16+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
17+
import com.fasterxml.jackson.annotation.JsonInclude;
18+
import com.fasterxml.jackson.annotation.JsonProperty;
19+
import com.fasterxml.jackson.annotation.JsonCreator;
20+
import com.fasterxml.jackson.annotation.JsonSubTypes;
21+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
22+
import com.fasterxml.jackson.annotation.JsonTypeName;
23+
import com.fasterxml.jackson.annotation.JsonValue;
24+
import org.openapitools.client.JSON;
25+
import org.openapitools.client.model.Pig;
26+
import org.openapitools.client.model.Whale;
27+
import org.openapitools.client.model.Zebra;
28+
29+
import org.junit.jupiter.api.Assertions;
30+
import org.junit.jupiter.api.Disabled;
31+
import org.junit.jupiter.api.Test;
32+
33+
/**
34+
* Model tests for Mammal
35+
*/
36+
public class MammalTest {
37+
private final Mammal model = new Mammal();
38+
39+
/**
40+
* Model tests for Mammal
41+
*/
42+
@Test
43+
public void testMammal() throws Exception {
44+
Mammal m = new Mammal();
45+
Zebra z = new Zebra();
46+
z.setType(Zebra.TypeEnum.MOUNTAIN);
47+
z.setClassName("zebra");
48+
m.setActualInstance(z);
49+
Assertions.assertEquals(JSON.getDefault().getMapper().writeValueAsString(m), "{\"type\":\"mountain\",\"className\":\"zebra\"}");
50+
}
51+
52+
/**
53+
* Model tests for getActualInstanceRecursively
54+
*/
55+
@Test
56+
public void testGetActualInstanceRecursively() throws Exception {
57+
Mammal m = new Mammal();
58+
Pig p = new Pig();
59+
DanishPig dp = new DanishPig();
60+
dp.setClassName("danish_pig");
61+
p.setActualInstance(dp);
62+
m.setActualInstance(p);
63+
Assertions.assertTrue(m.getActualInstanceRecursively() instanceof DanishPig);
64+
65+
Pig p2 = new Pig();
66+
m.setActualInstance(p2);
67+
Assertions.assertEquals(m.getActualInstanceRecursively(), null);
68+
}
69+
70+
/**
71+
* Test the property 'hasBaleen'
72+
*/
73+
@Test
74+
public void hasBaleenTest() {
75+
// TODO: test hasBaleen
76+
}
77+
78+
/**
79+
* Test the property 'hasTeeth'
80+
*/
81+
@Test
82+
public void hasTeethTest() {
83+
// TODO: test hasTeeth
84+
}
85+
86+
/**
87+
* Test the property 'className'
88+
*/
89+
@Test
90+
public void classNameTest() {
91+
// TODO: test className
92+
}
93+
94+
/**
95+
* Test the property 'type'
96+
*/
97+
@Test
98+
public void typeTest() {
99+
// TODO: test type
100+
}
101+
102+
/**
103+
* Test code sample
104+
*/
105+
@Test
106+
public void codeSampleTest() {
107+
Mammal exampleMammal = new Mammal();
108+
109+
// create a new Pig
110+
Pig examplePig = new Pig();
111+
// set Mammal to Pig
112+
exampleMammal.setActualInstance(examplePig);
113+
// to get back the Pig set earlier
114+
Pig testPig = (Pig) exampleMammal.getActualInstance();
115+
116+
// create a new Whale
117+
Whale exampleWhale = new Whale();
118+
// set Mammal to Whale
119+
exampleMammal.setActualInstance(exampleWhale);
120+
// to get back the Whale set earlier
121+
Whale testWhale = (Whale) exampleMammal.getActualInstance();
122+
123+
// create a new Zebra
124+
Zebra exampleZebra = new Zebra();
125+
// set Mammal to Zebra
126+
exampleMammal.setActualInstance(exampleZebra);
127+
// to get back the Zebra set earlier
128+
Zebra testZebra = (Zebra) exampleMammal.getActualInstance();
129+
}
130+
131+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* OpenAPI Petstore
3+
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package org.openapitools.client;
15+
16+
import com.fasterxml.jackson.databind.type.MapType;
17+
import com.fasterxml.jackson.databind.type.TypeFactory;
18+
import com.fasterxml.jackson.core.type.TypeReference;
19+
import com.fasterxml.jackson.annotation.JsonInclude;
20+
import com.fasterxml.jackson.annotation.JsonProperty;
21+
import com.fasterxml.jackson.annotation.JsonCreator;
22+
import com.fasterxml.jackson.annotation.JsonTypeName;
23+
import com.fasterxml.jackson.annotation.JsonValue;
24+
25+
import java.util.HashMap;
26+
import java.util.Map;
27+
28+
import org.openapitools.client.JSON;
29+
30+
import org.junit.jupiter.api.Assertions;
31+
import org.junit.jupiter.api.Disabled;
32+
import org.junit.jupiter.api.Test;
33+
34+
/**
35+
* Model tests for Zebra
36+
*/
37+
public class ZebraTest {
38+
private final Zebra model = new Zebra();
39+
40+
/**
41+
* Model tests for Zebra
42+
*/
43+
@Test
44+
public void testZebra() {
45+
Zebra z = new Zebra();
46+
z.setClassName("zebra");
47+
Map<String, String> m = new HashMap<>();
48+
z.putAdditionalProperty("key1", "value1");
49+
z.putAdditionalProperty("key2", 12321);
50+
z.setType(Zebra.TypeEnum.MOUNTAIN);
51+
52+
JSON j = new JSON();
53+
try {
54+
// serialize
55+
Assertions.assertEquals(j.getMapper().writeValueAsString(z), "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}");
56+
57+
// deserialize
58+
String zebraJson = "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}";
59+
Zebra zebraFromJson = j.getMapper().readValue(zebraJson, Zebra.class);
60+
Assertions.assertEquals(zebraFromJson.getType(), Zebra.TypeEnum.MOUNTAIN);
61+
Assertions.assertEquals(zebraFromJson.getClassName(), "zebra");
62+
Assertions.assertEquals(zebraFromJson.getAdditionalProperties().size(), 2);
63+
Assertions.assertEquals(zebraFromJson.getAdditionalProperty("key1"), "value1");
64+
Assertions.assertEquals(zebraFromJson.getAdditionalProperty("key2"), 12321);
65+
} catch (Exception ex) {
66+
Assertions.assertEquals(true, false); // exception shouldn't be thrown
67+
}
68+
}
69+
70+
/**
71+
* Test the property 'type'
72+
*/
73+
@Test
74+
public void typeTest() {
75+
String zebraJson = "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}";
76+
77+
JSON j = new JSON();
78+
TypeFactory typeFactory = j.getMapper().getTypeFactory();
79+
MapType mapType = typeFactory.constructMapType(HashMap.class, String.class, Object.class);
80+
try {
81+
HashMap<String, Object> map = j.getMapper().readValue(zebraJson, mapType);
82+
Assertions.assertEquals(map.get("type"), "mountain");
83+
84+
Map<String,Object> result =
85+
j.getMapper().readValue(zebraJson, new TypeReference<Map<String,Object>>() {});
86+
87+
Assertions.assertEquals(result.get("type"), "mountain");
88+
} catch (Exception ex) {
89+
Assertions.assertEquals(true, false); // exception shouldn't be thrown
90+
}
91+
}
92+
93+
/**
94+
* Test the property 'className'
95+
*/
96+
@Test
97+
public void classNameTest() {
98+
// TODO: test className
99+
}
100+
101+
}

0 commit comments

Comments
 (0)