### Question:
NodeDiskDao extends NamedParameterJdbcDaoSupport { @Transactional public List<NodeDisk> insert(final String nodeId, final List<DiskRegistrationRequest> requests) { return insert(nodeId, DateUtils.nowUTC(), requests); }  @Transactional List<NodeDisk> insert(final String nodeId, final List<DiskRegistrationRequest> requests); @Transactional List<NodeDisk> insert(final String nodeId, final LocalDateTime creationDate, 
                                 final List<DiskRegistrationRequest> requests); List<NodeDisk> loadByNodeId(final String nodeId);  }### Answer:
@Test public void insertShouldFailOnMissingNodeId() { assertThrows(DataIntegrityViolationException.class, () -> insert(NULL_NODE_ID, diskRequestOf(SIZE))); }
@Test public void insertShouldFailOnMissingSize() { assertThrows(DataIntegrityViolationException.class, () -> insert(NODE_ID, diskRequestOf(NULL_SIZE))); }
@Test public void insertShouldSaveDiskParameters() { final List<NodeDisk> disks = insert(NODE_ID, diskRequestOf(SIZE)); assertThat(disks.size(), is(1)); final NodeDisk disk = disks.get(0); assertThat(disk.getSize(), is(SIZE)); assertThat(disk.getNodeId(), is(NODE_ID)); final LocalDateTime expectedCreationDate = DateUtils.nowUTC(); final LocalDateTime lowerExpectedCreationDate = expectedCreationDate.minusMinutes(1); final LocalDateTime upperExpectedCreationDate = expectedCreationDate.plusMinutes(1); final LocalDateTime actualCreationDate = disk.getCreatedDate(); assertTrue(actualCreationDate.isAfter(lowerExpectedCreationDate) && actualCreationDate.isBefore(upperExpectedCreationDate)); }
@Test public void insertShouldInheritCreationDateIfSpecified() { final LocalDateTime creationDate = LocalDateTime.now(); final List<NodeDisk> disks = insert(NODE_ID, creationDate, diskRequestOf(SIZE), diskRequestOf(SIZE)); assertThat(disks.size(), is(2)); disks.forEach(disk -> assertThat(disk.getCreatedDate(), is(creationDate))); }
@Test public void insertShouldSaveAllDisks() { final List<NodeDisk> disks = insert(NODE_ID, diskRequestOf(SIZE), diskRequestOf(SIZE)); assertThat(disks.size(), is(2)); }
@Test public void insertShouldSaveAllDisksWithSameCreationDate() { final List<NodeDisk> disks = insert(NODE_ID, diskRequestOf(SIZE), diskRequestOf(SIZE)); final Set<LocalDateTime> creationDates = disks.stream() .map(NodeDisk::getCreatedDate) .collect(Collectors.toSet()); assertThat(creationDates.size(), is(1)); }