Skip to content

Commit

Permalink
Exclude enum test
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechhabarta committed May 4, 2017
1 parent 9ea922c commit eed856e
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

package cz.habarta.typescript.generator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.*;
import static org.junit.Assert.*;
import org.junit.Test;

Expand Down Expand Up @@ -104,6 +106,14 @@ public void testEmptyEnum() {
assertEquals(expected, output);
}

@Test
public void testExcludeObjectEnum() {
final Settings settings = TestUtils.settings();
settings.setExcludeFilter(Arrays.asList(StatusType.class.getName()), Arrays.<String>asList());
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(ClassWithObjectEnum.class, StatusType.class));
assertTrue(!output.contains("StatusType"));
}

private static class AClass {
public Direction direction;
}
Expand Down Expand Up @@ -143,4 +153,31 @@ public Object getJsonValue() {
enum EmptyEnum {
}

static class ClassWithObjectEnum {
public StatusType status;
public List<Map<String, StatusType>> statuses;
}

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum StatusType {
GOOD(0, "Good"),
FULL(1, "Full");

private final int code;
private final String label;

private StatusType(int code, String label) {
this.label = label;
this.code = code;
}

public int getCode() {
return code;
}

public String getLabel() {
return label;
}
}

}

0 comments on commit eed856e

Please sign in to comment.