use of org.onap.so.db.request.beans.OperationStatusId 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());
}
Aggregations