Skip to content

Commit

Permalink
property tests with string enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Reimann committed Feb 13, 2018
1 parent 42fb76e commit e2fb7a8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion opt4j-core/src/test/java/org/opt4j/core/config/PropertyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ public void setValueException() throws NoSuchMethodException, SecurityException,
p.setValue(3.0d);
}

@Test(expected = InvocationTargetException.class)
public void setValueExceptionString() throws NoSuchMethodException, SecurityException, InvocationTargetException {
Method setter = MyModuleMock.class.getMethod("setMockInt", Integer.class);
Property p = new Property(new MyModuleMock(), null, Integer.TYPE, null, setter,
Collections.<Annotation> emptySet());

p.setValue("3.0");
}

@Test
public void setValueLong() throws NoSuchMethodException, SecurityException, InvocationTargetException {
Method setter = MyModuleMock.class.getMethod("setMockLong", Long.class);
Expand Down Expand Up @@ -249,7 +258,7 @@ public void setValueEnum() throws NoSuchMethodException, SecurityException, Invo
Property p = new Property(new MyModuleMock(), null, MyEnum.class, null, setter,
Collections.<Annotation> emptySet());

p.setValue(MyEnum.X);
p.setValue("X");
}

enum MyEnum {
Expand Down Expand Up @@ -363,4 +372,10 @@ public void isNumberShort() {

Assert.assertTrue(p.isNumber());
}

@Test
public void getAnnotations() {
Property p = new Property(new MyModuleMock(), null, null, null, null, Collections.<Annotation> emptySet());
Assert.assertTrue(p.getAnnotations().isEmpty());
}
}

0 comments on commit e2fb7a8

Please sign in to comment.