Created
April 11, 2020 10:26
-
-
Save 0001vrn/e1807d1ec9818be1a79099d7ca249e85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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