Summary Table
Categories |
Total Count |
PII |
0 |
URL |
2 |
DNS |
2 |
EKL |
0 |
IP |
0 |
PORT |
2 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
package gov.va.med.ars.service.impl;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import java.util.Date;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.test.web.servlet.MockMvc;
import gov.va.med.ars.constants.IAuditLogConstants;
import gov.va.med.ars.dao.ars.IAuditLoggerRepository;
import gov.va.med.ars.dao.ars.IClaimAttachmentsViewRepository;
import gov.va.med.ars.exceptions.GenericException;
import gov.va.med.ars.model.request.AuditLogger;
import gov.va.med.domain.ars.Arsauditlog;
import gov.va.med.domain.ars.ClaimattachmentsView;
@RunWith(MockitoJUnitRunner.class)
public class FileOperationsServiceImplTest {
private static final Logger logger = LogManager.getLogger(FileOperationsServiceImplTest.class);
private MockMvc mockMvc;
@Mock
IAuditLoggerRepository auditLoggerRepository;
@Mock
IClaimAttachmentsViewRepository claimAttachmentRepository;
@InjectMocks
AuditLoggerServiceImpl auditLoggerService;
@Test
public void testMockIsWorking() {
assertNotNull("IAuditLoggerRepository Injection Failed", auditLoggerService);
}
@Test
public void testGetfileContentAndLog_success() throws GenericException{
AuditLogger auditLogger=new AuditLogger("VHANAME", "86753303.001", "ars", new Boolean("true"));
ClaimattachmentsView record = new ClaimattachmentsView();
record.setAttachIdLx("86753303.001");
record.setAttachmentId(86753303L);
record.setAttachmentControlNumber("6F40E5499721477EE053EAD8E30A5A2D");
record.setClaimIdentifier("100000");
record.setExternalClaimId("11111");
record.setStatus("Active");
record.setPatientFirstName("ORPHAN");
record.setPatientControlNumber("252525");
record.setPatientIdentifierNumber("34567");
record.setProviderName("2.2.1_PROVIDERINFO0015");
record.setProviderNpi("678947");
record.setMedicalRecordNumber("123456789");
record.setPayerClaimControlNumber("202154");
record.setReportCode("09");
record.setAttachmentType("PDF");
record.setClaimServiceStartDate("20161108");
record.setClaimServiceEndDate("20161225");
record.setAttachmentPath("https://
DNS.URL:PORT
/attachments/output/86753303.001/yalesample.tiff");
when(claimAttachmentRepository.findOneByAttachIdLx(auditLogger.getAttachIdLx())).thenReturn(record);
Arsauditlog arsAuditLog = new Arsauditlog(IAuditLogConstants.METHODNAME, auditLogger.getVhaName(), auditLogger.getAttachIdLx(), new Date(),
IAuditLogConstants.REQUESTARGS+auditLogger.getAttachIdLx(), IAuditLogConstants.DOWNLOADACTION, true, 1L);
when(auditLoggerRepository.save(arsAuditLog)).thenReturn(arsAuditLog);
String attachmentPath=auditLoggerService.getPathForTheAttachment(auditLogger);
// assertTrue(attachmentPath.equalsIgnoreCase("/u02/attachments/output/86753303.001/yalesample.tiff"));
// This should be looked into.
}
@Test(expected = Exception.class)
public void testGetfileContentAndLog_failure() throws GenericException{
AuditLogger auditLogger=new AuditLogger("VHANAME", "86753303.001","ars",new Boolean("false"));
ClaimattachmentsView record = new ClaimattachmentsView();
record.setAttachIdLx("86753303.001");
record.setAttachmentId(86753303L);
record.setAttachmentControlNumber("6F40E5499721477EE053EAD8E30A5A2D");
record.setClaimIdentifier("100000");
record.setExternalClaimId("11111");
record.setStatus("Active");
record.setPatientFirstName("ORPHAN");
record.setPatientControlNumber("252525");
record.setPatientIdentifierNumber("34567");
record.setProviderName("2.2.1_PROVIDERINFO0015");
record.setProviderNpi("678947");
record.setMedicalRecordNumber("123456789");
record.setPayerClaimControlNumber("202154");
record.setReportCode("09");
record.setAttachmentType("PDF");
record.setClaimServiceStartDate("20161108");
record.setClaimServiceEndDate("20161225");
record.setAttachmentPath("https://
DNS.URL:PORT
/attachments/output//86753303.001/yalesample.tiff");
when(claimAttachmentRepository.findOneByAttachIdLx(auditLogger.getAttachIdLx())).thenReturn(null);
Arsauditlog arsAuditLog = new Arsauditlog(IAuditLogConstants.METHODNAME, auditLogger.getVhaName(), auditLogger.getAttachIdLx(), new Date(),
IAuditLogConstants.REQUESTARGS+auditLogger.getAttachIdLx(), IAuditLogConstants.DOWNLOADACTION, true, 1L);
when(auditLoggerRepository.save(arsAuditLog)).thenReturn(arsAuditLog);
String attachmentPath=auditLoggerService.getPathForTheAttachment(auditLogger);
}
}