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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations