Skip to content

Commit

Permalink
Add test cast for enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
Airsaid committed Sep 5, 2021
1 parent 4909ba3 commit 848a132
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions okmock/src/test/java/com/airsaid/okmock/OKMockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import static org.junit.Assert.*;

import com.airsaid.okmock.data.Color;

/**
* @author airsaid
*/
Expand Down Expand Up @@ -109,4 +111,13 @@ public void getMockDataBySignatureNested() {
assertEquals(Integer.class, ((HashMap<?, ?>) mapValue).keySet().iterator().next().getClass());
assertEquals(String.class, ((HashMap<?, ?>) mapValue).values().iterator().next().getClass());
}

@Test
public void getMockDataByEnum() {
assertTrue(OKMock.getMockData("Lcom.airsaid.okmock.data.Color;") instanceof Color);

Object colorList = OKMock.getMockData("Ljava/util/List<Lcom.airsaid.okmock.data.Color;>;");
assertEquals(ArrayList.class, colorList.getClass());
assertTrue(((ArrayList<?>) colorList).get(0) instanceof Color);
}
}
16 changes: 16 additions & 0 deletions okmock/src/test/java/com/airsaid/okmock/data/Color.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.airsaid.okmock.data;

/**
* @author airsaid
*/
public enum Color {
RED(1),
BLUE(2),
YELLOW(3);

public final int value;

Color(int value) {
this.value = value;
}
}

0 comments on commit 848a132

Please sign in to comment.