Skip to content

Instantly share code, notes, and snippets.

@0001vrn
Created April 11, 2020 10:26
Show Gist options
  • Save 0001vrn/e1807d1ec9818be1a79099d7ca249e85 to your computer and use it in GitHub Desktop.
Save 0001vrn/e1807d1ec9818be1a79099d7ca249e85 to your computer and use it in GitHub Desktop.
class CassandraDbChgRequestRepositoryTest {
@Autowired
private SpringDataCassandraChgRequestRepository cassandraChgRequestRepository;
@Autowired
private ChgRequestRepository chgRequestRepository;
@AfterEach
void tearDown() {
cassandraChgRequestRepository.deleteAll();
}
@Test
void shouldFindAll_ThenReturnChgRequest() {
// Arrange
var alpha = new AppMetadata("alpha", "1.3.1", "random jira link", "prod-us-west-2", "rolling out new feature");
var alphaChgRequest = new ChgRequest(UUID.randomUUID(), alpha);
alphaChgRequest.createChgRequest(alpha);
// Act
chgRequestRepository.save(alphaChgRequest);
// Assert
assertNotNull(chgRequestRepository.findAll());
}
@Test
void shouldFindById_ThenReturnChgRequest() {
// Arrange
var tango = new AppMetadata("tango", "2.3.1", "random jira link", "prod-us-east-1", "rolling out new feature");
var chgRequest = new ChgRequest(UUID.randomUUID(), tango);
chgRequest.createChgRequest(tango);
// Act
chgRequestRepository.save(chgRequest);
var mayBeChgRequest = chgRequestRepository.findById(chgRequest.getId());
// Assert
mayBeChgRequest.ifPresent(chgRequestFromDao -> assertEquals(chgRequest.getId(), chgRequestFromDao.getId()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment