Search in sources :

Example 1 with NoEntityFoundException

use of org.onap.so.db.request.exceptions.NoEntityFoundException in project so by onap.

the class OperationStatusTest method timeStampCreated.

@Test
@Transactional
public void timeStampCreated() throws InterruptedException, NoEntityFoundException {
    final String testServiceId = "test-service-id";
    final String testOperationId = "test-operation-id";
    final OperationStatusId id = new OperationStatusId(testServiceId, testOperationId);
    OperationStatus status = new OperationStatus();
    status.setServiceId(testServiceId);
    status.setOperationId(testOperationId);
    status = repository.saveAndFlush(status);
    OperationStatus found = repository.findById(id).orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
    Date operateAt = found.getOperateAt();
    assertNotNull(operateAt);
    assertEquals(testServiceId, found.getServiceId());
    Date finishedAt = found.getFinishedAt();
    status.setProgress("test-progress");
    // timestamps only set to save on 1 second changes
    Thread.sleep(1000);
    repository.saveAndFlush(status);
    OperationStatus foundUpdate = repository.findById(id).orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
    assertEquals(operateAt.toString(), foundUpdate.getOperateAt().toString());
    assertNotNull(foundUpdate.getFinishedAt());
    assertNotEquals(finishedAt.toString(), foundUpdate.getFinishedAt().toString());
    assertEquals("test-progress", foundUpdate.getProgress());
}
Also used : OperationStatusId(org.onap.so.db.request.beans.OperationStatusId) OperationStatus(org.onap.so.db.request.beans.OperationStatus) NoEntityFoundException(org.onap.so.db.request.exceptions.NoEntityFoundException) Date(java.util.Date) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(javax.transaction.Transactional)

Example 2 with NoEntityFoundException

use of org.onap.so.db.request.exceptions.NoEntityFoundException in project so by onap.

the class OrchestrationTaskTest method timeStampCreated.

@Test
@Transactional
public void timeStampCreated() throws NoEntityFoundException {
    final String testTaskId = "test-task-id";
    final String testRequestId = "test-request-id";
    final String testTaskName = "test-task-name";
    final String testTaskStatus = "test-task-status";
    final String testIsManual = "test-is-manual";
    OrchestrationTask task = new OrchestrationTask();
    task.setTaskId(testTaskId);
    task.setRequestId(testRequestId);
    task.setName(testTaskName);
    task.setStatus(testTaskStatus);
    task.setIsManual(testIsManual);
    repository.saveAndFlush(task);
    OrchestrationTask found = repository.findById(testTaskId).orElseThrow(() -> new NoEntityFoundException("Cannot Find Task"));
    Date createdTime = found.getCreatedTime();
    assertNotNull(createdTime);
    assertEquals(testTaskId, found.getTaskId());
    assertEquals(testRequestId, found.getRequestId());
    assertEquals(testTaskName, found.getName());
    assertEquals(testTaskStatus, found.getStatus());
    assertEquals(testIsManual, found.getIsManual());
}
Also used : NoEntityFoundException(org.onap.so.db.request.exceptions.NoEntityFoundException) OrchestrationTask(org.onap.so.db.request.beans.OrchestrationTask) Date(java.util.Date) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(javax.transaction.Transactional)

Example 3 with NoEntityFoundException

use of org.onap.so.db.request.exceptions.NoEntityFoundException 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 4 with NoEntityFoundException

use of org.onap.so.db.request.exceptions.NoEntityFoundException in project so by onap.

the class OperationalEnvServiceModelStatusTest method updateWithoutAllKeys.

@Test
public void updateWithoutAllKeys() throws Exception {
    OperationalEnvServiceModelStatus status = new OperationalEnvServiceModelStatus();
    status.setRequestId("request-id-1");
    status.setOperationalEnvId("oper-env-id-1");
    status.setServiceModelVersionId("service-model-ver-id-1");
    status.setVnfOperationalEnvId("vnf-oper-env-id-1");
    status.setRetryCount(0);
    repository.saveAndFlush(status);
    OperationalEnvServiceModelStatus status2 = repository.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId("oper-env-id-1", "service-model-ver-id-1", "request-id-1");
    status2.setRetryCount(1);
    assertEquals("request-id-1", status2.getRequestId());
    assertEquals("vnf-oper-env-id-1", status2.getVnfOperationalEnvId());
    repository.saveAndFlush(status2);
    OperationalEnvServiceModelStatus status3 = new OperationalEnvServiceModelStatus();
    status3.setRequestId("request-id-2");
    status3.setOperationalEnvId("oper-env-id-1");
    status3.setServiceModelVersionId("service-model-ver-id-2");
    status3.setVnfOperationalEnvId("vnf-oper-env-id-2");
    status3.setRetryCount(2);
    repository.saveAndFlush(status3);
    OperationalEnvServiceModelStatus exampleObj = new OperationalEnvServiceModelStatus();
    exampleObj.setOperationalEnvId("oper-env-id-1");
    exampleObj.setServiceModelVersionId("service-model-ver-id-1");
    ExampleMatcher matcher = ExampleMatcher.matching().withIgnorePaths("requestId");
    OperationalEnvServiceModelStatus foundStatus = repository.findOne(Example.of(exampleObj, matcher)).orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
    if (foundStatus == null)
        throw new Exception("No status found");
    assertEquals(new Integer(1), foundStatus.getRetryCount());
}
Also used : NoEntityFoundException(org.onap.so.db.request.exceptions.NoEntityFoundException) ExampleMatcher(org.springframework.data.domain.ExampleMatcher) OperationalEnvServiceModelStatus(org.onap.so.db.request.beans.OperationalEnvServiceModelStatus) NoEntityFoundException(org.onap.so.db.request.exceptions.NoEntityFoundException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with NoEntityFoundException

use of org.onap.so.db.request.exceptions.NoEntityFoundException 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)

Aggregations

Test (org.junit.Test)5 NoEntityFoundException (org.onap.so.db.request.exceptions.NoEntityFoundException)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Transactional (javax.transaction.Transactional)3 Date (java.util.Date)2 SiteStatus (org.onap.so.db.request.beans.SiteStatus)2 OperationStatus (org.onap.so.db.request.beans.OperationStatus)1 OperationStatusId (org.onap.so.db.request.beans.OperationStatusId)1 OperationalEnvServiceModelStatus (org.onap.so.db.request.beans.OperationalEnvServiceModelStatus)1 OrchestrationTask (org.onap.so.db.request.beans.OrchestrationTask)1 ExampleMatcher (org.springframework.data.domain.ExampleMatcher)1