### Question:
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);  }### Answer:
@Test public void testCreateNullName() { NullPointerException e = assertThrows(NullPointerException.class, () -> { RecordFactory.create(null, mock(Structure.class)); }); assertThat(e.getMessage()).isEqualTo("Name must not be null"); }
@Test public void testCreateNullStructure() { NullPointerException e = assertThrows(NullPointerException.class, () -> { RecordFactory.create("name", null); }); assertThat(e.getMessage()).isEqualTo("Structure must not be null"); }
@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)); }