|
1 | 1 |
|
2 | 2 | package cz.habarta.typescript.generator;
|
3 | 3 |
|
| 4 | +import com.fasterxml.jackson.annotation.JsonFormat; |
4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty;
|
5 | 6 | import com.fasterxml.jackson.annotation.JsonValue;
|
| 7 | +import java.util.*; |
6 | 8 | import static org.junit.Assert.*;
|
7 | 9 | import org.junit.Test;
|
8 | 10 |
|
@@ -104,6 +106,14 @@ public void testEmptyEnum() {
|
104 | 106 | assertEquals(expected, output);
|
105 | 107 | }
|
106 | 108 |
|
| 109 | + @Test |
| 110 | + public void testExcludeObjectEnum() { |
| 111 | + final Settings settings = TestUtils.settings(); |
| 112 | + settings.setExcludeFilter(Arrays.asList(StatusType.class.getName()), Arrays.<String>asList()); |
| 113 | + final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(ClassWithObjectEnum.class, StatusType.class)); |
| 114 | + assertTrue(!output.contains("StatusType")); |
| 115 | + } |
| 116 | + |
107 | 117 | private static class AClass {
|
108 | 118 | public Direction direction;
|
109 | 119 | }
|
@@ -143,4 +153,31 @@ public Object getJsonValue() {
|
143 | 153 | enum EmptyEnum {
|
144 | 154 | }
|
145 | 155 |
|
| 156 | + static class ClassWithObjectEnum { |
| 157 | + public StatusType status; |
| 158 | + public List<Map<String, StatusType>> statuses; |
| 159 | + } |
| 160 | + |
| 161 | + @JsonFormat(shape = JsonFormat.Shape.OBJECT) |
| 162 | + public enum StatusType { |
| 163 | + GOOD(0, "Good"), |
| 164 | + FULL(1, "Full"); |
| 165 | + |
| 166 | + private final int code; |
| 167 | + private final String label; |
| 168 | + |
| 169 | + private StatusType(int code, String label) { |
| 170 | + this.label = label; |
| 171 | + this.code = code; |
| 172 | + } |
| 173 | + |
| 174 | + public int getCode() { |
| 175 | + return code; |
| 176 | + } |
| 177 | + |
| 178 | + public String getLabel() { |
| 179 | + return label; |
| 180 | + } |
| 181 | + } |
| 182 | + |
146 | 183 | }
|
0 commit comments