Search in sources :

Example 1 with SiteStatus

use of org.onap.so.db.request.beans.SiteStatus in project so by onap.

the class SiteStatusTest method timeStampCreated.

@Test
@Transactional
public void timeStampCreated() throws InterruptedException, NoEntityFoundException {
    SiteStatus found = repository.findById("test name4").orElseThrow(() -> new NoEntityFoundException("Cannot Find Site"));
    assertNotNull(found.getCreated());
    assertEquals("test name4", found.getSiteName());
}
Also used : NoEntityFoundException(org.onap.so.db.request.exceptions.NoEntityFoundException) SiteStatus(org.onap.so.db.request.beans.SiteStatus) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(javax.transaction.Transactional)

Example 2 with SiteStatus

use of org.onap.so.db.request.beans.SiteStatus in project so by onap.

the class SiteStatusTest method sortByCreated.

@Test
public void sortByCreated() {
    final PageRequest page1 = PageRequest.of(0, 20, Direction.DESC, "created");
    SiteStatus example = new SiteStatus();
    example.setStatus(true);
    Page<SiteStatus> found = repository.findAll(Example.of(example), page1);
    assertEquals("test name4", found.getContent().get(0).getSiteName());
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) SiteStatus(org.onap.so.db.request.beans.SiteStatus) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with SiteStatus

use of org.onap.so.db.request.beans.SiteStatus in project so by onap.

the class SiteStatusTest method updateStatus.

@Test
public void updateStatus() throws NoEntityFoundException {
    SiteStatus status = repository.findById("test name update").orElseThrow(() -> new NoEntityFoundException("Cannot Find Site"));
    status.setStatus(false);
    repository.saveAndFlush(status);
    status = repository.findById("test name update").orElseThrow(() -> new NoEntityFoundException("Cannot Find Site"));
    assertEquals(false, status.getStatus());
}
Also used : NoEntityFoundException(org.onap.so.db.request.exceptions.NoEntityFoundException) SiteStatus(org.onap.so.db.request.beans.SiteStatus) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SiteStatus

use of org.onap.so.db.request.beans.SiteStatus in project so by onap.

the class MsoRequestsDbAdapterImpl method getSiteStatus.

/**
 * Get SiteStatus by SiteName.
 *
 * @param siteName The unique name of the site
 * @return Status of that site
 */
@Override
@Transactional
public boolean getSiteStatus(String siteName) {
    SiteStatus siteStatus;
    logger.debug("Request database - get Site Status with Site name: {}", siteName);
    siteStatus = siteRepo.findOneBySiteName(siteName);
    if (siteStatus == null) {
        // return true
        return true;
    } else {
        return siteStatus.getStatus();
    }
}
Also used : SiteStatus(org.onap.so.db.request.beans.SiteStatus) Transactional(javax.transaction.Transactional)

Aggregations

SiteStatus (org.onap.so.db.request.beans.SiteStatus)4 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (javax.transaction.Transactional)2 NoEntityFoundException (org.onap.so.db.request.exceptions.NoEntityFoundException)2 PageRequest (org.springframework.data.domain.PageRequest)1