/** * Creates a float custom object for testing. * * @param <T> type of float custom object * @param type of float custom object * @return instance of float custom object */ public static <T extends FloatCustomObject> T createCustomObject(final Class<T> type) { // CheckStyle:MagicNumber OFF final Set<Float> s1 = new HashSet<Float>(); s1.add(601.6f); s1.add(602.6f); final T o1; try { o1 = type.newInstance(); } catch (InstantiationException e) { throw new IllegalStateException(e); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } o1.setFloatDn("cn=Float Entry,ou=people,dc=ldaptive,dc=org"); o1.setType1(100.1f); o1.writeType2(200.2f); o1.setType3(300.3f); o1.setTypeArray1(new Float[] {301.1f, 302.2f}); o1.writeTypeArray2(new Float[] {301.1f, 302.2f}); o1.setTypeCol1(Arrays.asList(501.5f, 502.5f)); o1.writeTypeCol2(Arrays.asList(501.5f, 502.5f)); o1.setTypeSet1(s1); o1.writeTypeSet2(s1); o1.setTypeList1(Arrays.asList(701.7f, 702.7f)); o1.writeTypeList2(Arrays.asList(701.7f, 702.7f)); return o1; // CheckStyle:MagicNumber ON }
/** * Creates a binary custom object for testing. * * @param <T> type of binary custom object * @param type of binary custom object * @return instance of binary custom object */ public static <T extends BinaryCustomObject> T createCustomObject(final Class<T> type) { // CheckStyle:MagicNumber OFF final Set<byte[]> s1 = new LinkedHashSet<>(); s1.add(new byte[] {0x22, 0x0F, 0x1F}); s1.add(new byte[] {0x23}); final T o1; try { o1 = type.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new IllegalStateException(e); } o1.setType1(new byte[] {0x01}); o1.writeType2(new byte[] {0x02, 0x0F}); o1.setType3(new byte[] {0x03, 0x0F, 0x1F}); o1.setTypeCol1(Arrays.asList(new byte[] {0x20, 0x0F, 0x1F}, new byte[] {0x21})); o1.writeTypeCol2(Arrays.asList(new byte[] {0x20, 0x0F, 0x1F}, new byte[] {0x21})); o1.setTypeSet1(s1); o1.writeTypeSet2(s1); o1.setTypeList1(Arrays.asList(new byte[] {0x24, 0x0F, 0x1F}, new byte[] {0x25})); o1.writeTypeList2(Arrays.asList(new byte[] {0x24, 0x0F, 0x1F}, new byte[] {0x25})); return o1; // CheckStyle:MagicNumber ON }
/** * Creates a boolean custom object for testing. * * @param <T> type of boolean custom object * @param type of boolean custom object * @return instance of boolean custom object */ public static <T extends BooleanCustomObject> T createCustomObject(final Class<T> type) { final Set<Boolean> s1 = new HashSet<Boolean>(); s1.add(true); s1.add(false); final T o1; try { o1 = type.newInstance(); } catch (InstantiationException e) { throw new IllegalStateException(e); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } o1.setType1(true); o1.writeType2(false); o1.setType3(true); o1.setTypeArray1(new boolean[] {false, true}); o1.writeTypeArray2(new boolean[] {false, true}); o1.setTypeCol1(Arrays.asList(true, false)); o1.writeTypeCol2(Arrays.asList(false, true)); o1.setTypeSet1(s1); o1.writeTypeSet2(s1); o1.setTypeList1(Arrays.asList(false, true)); o1.writeTypeList2(Arrays.asList(true, false)); return o1; }