Skip to content

Commit 4337559

Browse files
authored
Merge pull request #79 from zalando-stups/add-test-with-enum
Add test which returns enum from a function
2 parents 92bc032 + 944c910 commit 4337559

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE OR REPLACE FUNCTION ztest_schema1.return_enum_from_function() RETURNS example_enum AS
2+
$BODY$
3+
DECLARE
4+
r ztest_schema1.example_enum;
5+
BEGIN
6+
select 'ENUM_CONST_1'::example_enum into r;
7+
return r;
8+
END;
9+
$BODY$ LANGUAGE plpgsql;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,6 @@ int createOrder(@SProcParam String orderNumber, @SProcParam OrderMonetaryAmount
292292
@SProcCall
293293
List<ExampleEnumDomainObject> listExampleEnumDomainObjects();
294294

295+
@SProcCall
296+
ExampleEnum returnEnumFromFunction();
295297
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,4 +464,9 @@ public ExampleEnumDomainObject getExampleEnumDomainObject(Integer id) {
464464
public List<ExampleEnumDomainObject> listExampleEnumDomainObjects() {
465465
return sproc.listExampleEnumDomainObjects();
466466
}
467+
468+
@Override
469+
public ExampleEnum returnEnumFromFunction() {
470+
return sproc.returnEnumFromFunction();
471+
}
467472
}

src/test/java/org/zalando/typemapper/namedresult/EnumTestIT.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99

1010
import org.junit.runner.RunWith;
1111

12+
import org.springframework.beans.factory.annotation.Autowired;
13+
import org.springframework.test.context.ContextConfiguration;
1214
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1315

1416

17+
import static org.junit.Assert.assertNotNull;
18+
19+
20+
import org.zalando.sprocwrapper.example.ExampleSProcService;
1521
import org.zalando.typemapper.AbstractTest;
1622
import org.zalando.typemapper.namedresult.results.ClassWithEmbedEnumClass;
1723
import org.zalando.typemapper.core.TypeMapper;
@@ -20,8 +26,12 @@
2026
import org.zalando.typemapper.namedresult.results.Enumeration;
2127

2228
@RunWith(SpringJUnit4ClassRunner.class)
29+
@ContextConfiguration(locations = {"classpath:backendContextTest.xml"})
2330
public class EnumTestIT extends AbstractTest {
2431

32+
@Autowired
33+
private ExampleSProcService exampleSProcService;
34+
2535
@Test
2636
public void testEnumMappings() throws SQLException {
2737
final PreparedStatement ps = connection.prepareStatement("SELECT 0 as a, 'VALUE_2' as b");
@@ -65,4 +75,9 @@ public void testEnumMappingsWithEnumInComplexType() throws SQLException {
6575
Assert.assertEquals(Enumeration.VALUE_2, result.getEmbeddedEnum().getValue2());
6676
}
6777
}
78+
79+
@Test
80+
public void testReturnEnumValue() {
81+
assertNotNull(exampleSProcService.returnEnumFromFunction());
82+
}
6883
}

0 commit comments

Comments
 (0)