@Test public void testHappyPath() { final Structure mockStructure = mock(Structure.class); final Field mockField1 = mock(Field.class); final Field mockField2 = mock(Field.class); when(mockField1.getName()).thenReturn("name"); when(mockField1.getType()).thenReturn(DataType.VC); when(mockField2.getName()).thenReturn("id"); when(mockField2.getType()).thenReturn(DataType.F8); when(mockStructure.getFields()).thenReturn(Arrays.asList(mockField1, mockField2)); final Record record = RecordFactory.create("name", mockStructure); assertThat(record.getName()).isEqualTo("name"); final Structure structure = record.getStructure(); final List<Field> fields = structure.getFields(); assertThat(fields.size()).isEqualTo(2); assertThat(fields.contains(mockField1)); assertThat(fields.contains(mockField2)); }
public static Record create(final String name, final Structure structure) { if (name == null) throw new NullPointerException("Name must not be null"); if (structure == null) throw new NullPointerException("Structure must not be null"); return RECORD_FACTORY.createRootRecord(name, structure); }
RecordFactory { public static Record create(final String name, final Structure structure) { if (name == null) throw new NullPointerException("Name must not be null"); if (structure == null) throw new NullPointerException("Structure must not be null"); return RECORD_FACTORY.createRootRecord(name, structure); } }
RecordFactory { public static Record create(final String name, final Structure structure) { if (name == null) throw new NullPointerException("Name must not be null"); if (structure == null) throw new NullPointerException("Structure must not be null"); return RECORD_FACTORY.createRootRecord(name, structure); }  }
RecordFactory { public static Record create(final String name, final Structure structure) { if (name == null) throw new NullPointerException("Name must not be null"); if (structure == null) throw new NullPointerException("Structure must not be null"); return RECORD_FACTORY.createRootRecord(name, structure); }  static Record create(final String name, final Structure structure); }
RecordFactory { public static Record create(final String name, final Structure structure) { if (name == null) throw new NullPointerException("Name must not be null"); if (structure == null) throw new NullPointerException("Structure must not be null"); return RECORD_FACTORY.createRootRecord(name, structure); }  static Record create(final String name, final Structure structure);  }