Skip to content

Commit b68ef68

Browse files
Added test for List<EnumType>
1 parent a89773f commit b68ef68

File tree

7 files changed

+74
-0
lines changed

7 files changed

+74
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TYPE example_enum_domain_object AS (
2+
id INT,
3+
enum_array ztest_schema1.example_enum[]
4+
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE enum_table (
2+
et_id serial primary key,
3+
et_enum_array ztest_schema1.example_enum[]
4+
);
5+
6+
INSERT INTO enum_table ( et_id, et_enum_array )
7+
VALUES (1, '{ENUM_CONST_1, ENUM_CONST_2}');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE OR REPLACE FUNCTION get_example_enum_domain_object(IN param_id INT)
2+
RETURNS example_enum_domain_object AS
3+
$BODY$
4+
5+
SELECT et_id,
6+
et_enum_array
7+
FROM enum_table
8+
WHERE et_id = $1;
9+
10+
$BODY$
11+
LANGUAGE 'sql' VOLATILE
12+
SECURITY DEFINER
13+
COST 100;

src/test/java/org/zalando/sprocwrapper/SimpleIT.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.zalando.sprocwrapper.example.ExampleDomainObjectWithSimpleTransformer;
5454
import org.zalando.sprocwrapper.example.ExampleDomainObjectWithValidation;
5555
import org.zalando.sprocwrapper.example.ExampleEnum;
56+
import org.zalando.sprocwrapper.example.ExampleEnumDomainObject;
5657
import org.zalando.sprocwrapper.example.ExampleNamespacedSProcService;
5758
import org.zalando.sprocwrapper.example.ExampleSProcService;
5859
import org.zalando.sprocwrapper.example.ExampleValidationSProcService;
@@ -1086,4 +1087,10 @@ public void testNullComplexParam() throws Exception {
10861087
public void testNullEnumParam() {
10871088
exampleSProcService.useEnumParam(null);
10881089
}
1090+
1091+
@Test
1092+
public void testEnumList() {
1093+
ExampleEnumDomainObject result = exampleSProcService.getExampleEnumDomainObject(1);
1094+
assertEquals(Lists.newArrayList(ExampleEnum.ENUM_CONST_1, ExampleEnum.ENUM_CONST_2), result.getEnumArray());
1095+
}
10891096
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.zalando.sprocwrapper.example;
2+
3+
import java.util.List;
4+
5+
import org.zalando.typemapper.annotations.DatabaseField;
6+
import org.zalando.typemapper.annotations.DatabaseType;
7+
8+
/**
9+
* @author mschumacher
10+
*/
11+
@DatabaseType
12+
public class ExampleEnumDomainObject {
13+
14+
@DatabaseField
15+
private Integer id;
16+
17+
@DatabaseField
18+
private List<ExampleEnum> enumArray;
19+
20+
public Integer getId() {
21+
return id;
22+
}
23+
24+
public void setId(Integer id) {
25+
this.id = id;
26+
}
27+
28+
public List<ExampleEnum> getEnumArray() {
29+
return enumArray;
30+
}
31+
32+
public void setEnumArray(List<ExampleEnum> enumArray) {
33+
this.enumArray = enumArray;
34+
}
35+
}

src/test/java/org/zalando/sprocwrapper/example/ExampleSProcService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,7 @@ int createOrder(@SProcParam String orderNumber, @SProcParam OrderMonetaryAmount
286286
@SProcCall
287287
PartialObject getPartialObject(@SProcParam NotPartialObject partialObject);
288288

289+
@SProcCall
290+
ExampleEnumDomainObject getExampleEnumDomainObject(@SProcParam Integer id);
291+
289292
}

src/test/java/org/zalando/sprocwrapper/example/ExampleSProcServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,4 +454,9 @@ public PartialObject getPartialObject(final PartialObject partialObject) {
454454
public PartialObject getPartialObject(final NotPartialObject notPartialObject) {
455455
return sproc.getPartialObject(notPartialObject);
456456
}
457+
458+
@Override
459+
public ExampleEnumDomainObject getExampleEnumDomainObject(Integer id) {
460+
return sproc.getExampleEnumDomainObject(id);
461+
}
457462
}

0 commit comments

Comments
 (0)