use of com.yahoo.athenz.common.server.workload.WorkloadRecord in project athenz by yahoo.
the class DynamoDBWorkloadRecordStoreConnectionTest method testUpdateWorkloadRecordException.
@Test
public void testUpdateWorkloadRecordException() {
WorkloadRecord workloadRecord = new WorkloadRecord();
Mockito.doThrow(new AmazonDynamoDBException("invalid operation")).when(table).updateItem(ArgumentMatchers.any(UpdateItemSpec.class));
DynamoDBWorkloadRecordStoreConnection dbConn = getDBConnection();
boolean requestSuccess = dbConn.updateWorkloadRecord(workloadRecord);
Assert.assertFalse(requestSuccess);
dbConn.close();
}
use of com.yahoo.athenz.common.server.workload.WorkloadRecord in project athenz by yahoo.
the class DynamoDBWorkloadRecordStoreConnection method itemToWorkloadRecord.
private WorkloadRecord itemToWorkloadRecord(Item item) {
WorkloadRecord workloadRecord = new WorkloadRecord();
workloadRecord.setInstanceId(item.getString(KEY_INSTANCE_ID));
workloadRecord.setService(item.getString(KEY_SERVICE));
workloadRecord.setIp(item.getString(KEY_IP));
if (item.hasAttribute(KEY_HOSTNAME)) {
workloadRecord.setHostname(item.getString(KEY_HOSTNAME));
} else {
workloadRecord.setHostname(DEFAULT_HOSTNAME_IF_NULL);
}
workloadRecord.setProvider(item.getString(KEY_PROVIDER));
workloadRecord.setCreationTime(DynamoDBUtils.getDateFromItem(item, KEY_CREATION_TIME));
workloadRecord.setUpdateTime(DynamoDBUtils.getDateFromItem(item, KEY_UPDATE_TIME));
if (item.hasAttribute(KEY_EXPIRY_TIME)) {
workloadRecord.setCertExpiryTime(DynamoDBUtils.getDateFromItem(item, KEY_EXPIRY_TIME));
} else {
// setting default date to 01/01/1970.
workloadRecord.setCertExpiryTime(new Date(0));
}
return workloadRecord;
}
Aggregations