Skip to content

Instantly share code, notes, and snippets.

@0001vrn
Created April 11, 2020 10:26
Show Gist options
  • Select an option

  • Save 0001vrn/e1807d1ec9818be1a79099d7ca249e85 to your computer and use it in GitHub Desktop.

Select an option

Save 0001vrn/e1807d1ec9818be1a79099d7ca249e85 to your computer and use it in GitHub Desktop.

Revisions

  1. 0001vrn created this gist Apr 11, 2020.
    43 changes: 43 additions & 0 deletions CassandraDbChgRequestRepositoryTest.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    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()));
    }
    }