Search in sources :

Example 1 with Transaction

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());
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Transaction

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());
}
Also used : AffectedParty(ca.bc.gov.hlth.hnweb.persistence.entity.AffectedParty) Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with Transaction

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);
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction) UserInfo(ca.bc.gov.hlth.hnweb.security.UserInfo) UnknownHostException(java.net.UnknownHostException) Date(java.util.Date)

Example 4 with 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;
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)

Example 5 with 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;
}
Also used : Transaction(ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)

Aggregations

Transaction (ca.bc.gov.hlth.hnweb.persistence.entity.Transaction)33 PostMapping (org.springframework.web.bind.annotation.PostMapping)14 Test (org.junit.jupiter.api.Test)5 ResponseStatusException (org.springframework.web.server.ResponseStatusException)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 TransactionEvent (ca.bc.gov.hlth.hnweb.persistence.entity.TransactionEvent)3 Message (ca.uhn.hl7v2.model.Message)3 LookupPhnResponse (ca.bc.gov.hlth.hnweb.model.rest.eligibility.LookupPhnResponse)2 BaseControllerTest (ca.bc.gov.hlth.hnweb.BaseControllerTest)1 E45Converter (ca.bc.gov.hlth.hnweb.converter.hl7v2.E45Converter)1 R15Converter (ca.bc.gov.hlth.hnweb.converter.hl7v2.R15Converter)1 R50Converter (ca.bc.gov.hlth.hnweb.converter.hl7v2.R50Converter)1 FindCandidatesConverter (ca.bc.gov.hlth.hnweb.converter.hl7v3.FindCandidatesConverter)1 GetDemographicsConverter (ca.bc.gov.hlth.hnweb.converter.hl7v3.GetDemographicsConverter)1 RPBSPCI0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPCI0Converter)1 RPBSPED0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPED0Converter)1 RPBSPEE0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPEE0Converter)1 RPBSPMC0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPMC0Converter)1 RPBSPPE0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPE0Converter)1 RPBSPPL0Converter (ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPPL0Converter)1