Skip to content

Commit e5cb88a

Browse files
committed
fix unit tests
1 parent e1efccf commit e5cb88a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lightblue-ldap-crud/src/test/java/com/redhat/lightblue/crud/ldap/EntryBuilderTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.junit.Assert.assertNotNull;
2626
import static org.junit.Assert.assertNull;
2727

28+
import java.math.BigInteger;
2829
import java.util.Arrays;
2930
import java.util.Collection;
3031
import java.util.Date;
@@ -35,16 +36,22 @@
3536
import org.junit.runner.RunWith;
3637
import org.junit.runners.Parameterized;
3738
import org.junit.runners.Parameterized.Parameters;
39+
import org.junit.runners.Suite;
40+
import org.junit.runners.Suite.SuiteClasses;
3841

3942
import com.redhat.lightblue.common.ldap.LdapConstant;
4043
import com.redhat.lightblue.common.ldap.LightblueUtil;
44+
import com.redhat.lightblue.crud.ldap.EntryBuilderTest.ParameterizedTests;
45+
import com.redhat.lightblue.crud.ldap.EntryBuilderTest.SpecializedTests;
4146
import com.redhat.lightblue.metadata.EntityMetadata;
4247
import com.redhat.lightblue.metadata.types.DateType;
4348
import com.redhat.lightblue.test.MetadataUtil;
4449
import com.redhat.lightblue.util.JsonDoc;
4550
import com.unboundid.ldap.sdk.Entry;
4651
import com.unboundid.util.StaticUtils;
4752

53+
@RunWith(Suite.class)
54+
@SuiteClasses({ParameterizedTests.class, SpecializedTests.class})
4855
public class EntryBuilderTest {
4956

5057
protected static Entry buildEntry(String fieldName, String metadataType, String crudValue) throws Exception{
@@ -120,6 +127,10 @@ public static Collection<Object[]> data() {
120127
{"{\"type\": \"string\"}", quote("teststring"), "teststring"},
121128
{"{\"type\": \"integer\"}", "4", null},
122129
{"{\"type\": \"boolean\"}", "true", null},
130+
{"{\"type\": \"bigdecimal\"}", String.valueOf(Double.MAX_VALUE), "1.7976931348623157E+308"},
131+
{"{\"type\": \"biginteger\"}", BigInteger.ZERO.toString(), BigInteger.ZERO.toString()},
132+
{"{\"type\": \"double\"}", String.valueOf(Double.MAX_VALUE), String.valueOf(Double.MAX_VALUE)},
133+
{"{\"type\": \"uid\"}", quote("fake-uid"), "fake-uid"},
123134
{"{\"type\": \"date\"}", quote(DateType.getDateFormat().format(now)), StaticUtils.encodeGeneralizedTime(now)},
124135
{"{\"type\": \"binary\"}", quote(DatatypeConverter.printBase64Binary("test binary data".getBytes())), "test binary data"},
125136
{"{\"type\": \"array\", \"items\": {\"type\": \"string\"}}", "[\"hello\",\"world\"]", new String[]{"hello", "world"}},

lightblue-ldap-crud/src/test/java/com/redhat/lightblue/crud/ldap/translator/ResultTranslatorTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@ public void testTranslate_SimpleField_UIDType() throws JSONException{
220220
true);
221221
}
222222

223+
@Test(expected = NullPointerException.class)
224+
public void testTranslate_SimpleField_NullValue() throws JSONException{
225+
SearchResult result = fakeSearchResult(
226+
new SearchResultEntry(-1, "uid=john.doe,dc=example,dc=com", new Attribute[]{
227+
new Attribute("uid")
228+
}));
229+
230+
EntityMetadata md = fakeEntityMetadata("fakeMetadata",
231+
new SimpleField("uid", StringType.TYPE)
232+
);
233+
234+
new ResultTranslator(factory).translate(result, md);
235+
}
236+
223237
@Test
224238
public void testTranslate_SimpleField_BinaryType() throws Exception{
225239
byte[] bite = new byte[]{1, 2, 3, 'a', 'b', 'c'};

0 commit comments

Comments
 (0)