use of ca.bc.gov.hlth.hnweb.persistence.entity.Transaction in project moh-hnweb by bcgov.
the class AuditServiceTest method testCreateTransaction.
@Test
public void testCreateTransaction() {
Transaction newTransaction = auditService.createTransaction("0:0:0:0:0:0:0:1", TransactionType.CHECK_ELIGIBILITY);
Optional<Transaction> optional = transactionRepository.findById(newTransaction.getTransactionId());
assertTrue(optional.isPresent());
Transaction transaction = optional.get();
assertEquals("00000010", transaction.getOrganization());
assertNotNull(transaction.getServer());
assertNotNull(transaction.getSessionId());
assertEquals("0:0:0:0:0:0:0:1", transaction.getSourceIp());
assertNotNull(transaction.getStartTime());
assertNotNull(transaction.getTransactionId());
assertEquals(TransactionType.CHECK_ELIGIBILITY.getValue(), transaction.getType());
assertEquals("unittest", transaction.getUserId());
}
use of ca.bc.gov.hlth.hnweb.persistence.entity.Transaction in project moh-hnweb by bcgov.
the class AuditServiceTest method testCreateAffectedParty.
@Test
public void testCreateAffectedParty() {
Transaction transaction = auditService.createTransaction("0:0:0:0:0:0:0:1", TransactionType.CHECK_ELIGIBILITY);
AffectedParty newAffectedParty = auditService.createAffectedParty(transaction, IdentifierType.GROUP_NUMBER, "6337109");
Optional<AffectedParty> optional = affectedPartyRepository.findById(newAffectedParty.getAffectedPartyId());
assertTrue(optional.isPresent());
AffectedParty affectedParty = optional.get();
assertNotNull(affectedParty.getAffectedPartyId());
assertEquals("6337109", affectedParty.getIdentifier());
assertEquals(IdentifierType.GROUP_NUMBER.getValue(), affectedParty.getIdentifierType());
assertEquals(transaction, affectedParty.getTransaction());
}
use of ca.bc.gov.hlth.hnweb.persistence.entity.Transaction in project moh-hnweb by bcgov.
the class AuditService method createTransaction.
/**
* Creates a new {@link Transaction}.
*
* @param sourceIP Source IP address
* @param type The type of transaction
* @return The persisted Transaction
*/
public Transaction createTransaction(String sourceIP, TransactionType type) {
Transaction transaction = new Transaction();
UserInfo userInfo = null;
try {
// This can throw an exception under certain auth failures
// E.g. if an empty or invalid token is provided
userInfo = SecurityUtil.loadUserInfo();
} catch (Exception e) {
// Ignore
}
transaction.setOrganization(userInfo != null ? userInfo.getOrganization() : null);
transaction.setServer(getServer());
transaction.setSessionId(userInfo != null ? userInfo.getSessionState() : null);
transaction.setSourceIp(sourceIP);
transaction.setStartTime(new Date());
transaction.setTransactionId(UUID.randomUUID());
transaction.setType(type.getValue());
transaction.setUserId(userInfo != null ? userInfo.getUsername() : null);
return transactionRepository.save(transaction);
}
use of ca.bc.gov.hlth.hnweb.persistence.entity.Transaction in project moh-hnweb by bcgov.
the class MspContractsController method auditContractInquiryStart.
private Transaction auditContractInquiryStart(ContractInquiryRequest contractInquiryRequest, HttpServletRequest request) {
Transaction transaction = transactionStart(request, TransactionType.CONTRACT_INQUIRY);
addAffectedParty(transaction, IdentifierType.PHN, contractInquiryRequest.getPhn());
addAffectedParty(transaction, IdentifierType.GROUP_NUMBER, contractInquiryRequest.getGroupNumber());
return transaction;
}
use of ca.bc.gov.hlth.hnweb.persistence.entity.Transaction in project moh-hnweb by bcgov.
the class MspContractsController method auditGetContractPeriodsStart.
private Transaction auditGetContractPeriodsStart(GetContractPeriodsRequest getContractPeriodsRequest, HttpServletRequest request) {
Transaction transaction = transactionStart(request, TransactionType.GET_CONTRACT_PERIODS);
addAffectedParty(transaction, IdentifierType.PHN, getContractPeriodsRequest.getPhn());
return transaction;
}
Aggregations