Skip to content

Commit

Permalink
Merge pull request #224 from ResearchCollectionsAndPreservation/stage…
Browse files Browse the repository at this point in the history
…4-dev

Dev to UAT
  • Loading branch information
srinduri04 authored Sep 21, 2021
2 parents a9b25e7 + ada6f52 commit 8a02a52
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import org.recap.ims.connector.AbstractLASImsLocationConnector;
import org.recap.model.IMSConfigProperties;
import org.recap.util.PropertyUtil;
import org.springframework.test.util.ReflectionTestUtils;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;


Expand All @@ -35,8 +38,10 @@ public class LASImsLocationConnectorFactoryUT extends BaseTestCaseUT {
public void getLasImsLocationConnector(){
imsLocationConnectors.add(abstractLASImsLocationConnector);
lasImsLocationConnectorFactory = new LASImsLocationConnectorFactory();
ReflectionTestUtils.setField(lasImsLocationConnectorFactory,"propertyUtil",propertyUtil);
Mockito.when(propertyUtil.getIMSConfigProperties(any())).thenReturn(imsConfigProperties);
Mockito.when(abstractLASImsLocationConnector.supports("HD")).thenReturn(true);
lasImsLocationConnectorFactory.getLasImsLocationConnector("HD");
//Mockito.when(abstractLASImsLocationConnector.supports("HD")).thenReturn(true);
AbstractLASImsLocationConnector abstractLASImsLocationConnector = lasImsLocationConnectorFactory.getLasImsLocationConnector("HD");
assertNotNull(abstractLASImsLocationConnector);
}
}
16 changes: 16 additions & 0 deletions src/test/java/org/recap/request/service/EmailServiceUT.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.recap.PropertyKeyConstants;
import org.recap.ScsbConstants;
import org.recap.ScsbCommonConstants;
import org.recap.request.service.EmailService;
import org.recap.util.PropertyUtil;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;

/**
* Created by sudhishk on 19/1/17.
Expand All @@ -38,4 +41,17 @@ public void testRecalEmail() {
emailService.sendEmail("", "PULTST54323", "RECAP","Message", "45678912", "","");
emailService.sendBulkRequestEmail("12","TestFirstBulkRequest","TestFirstBulkRequest","PROCESSED","Test","");
}

@Test
public void sendLASExceptionEmail(){
String customerCode = "PA";
String itemBarcode = "243533";
String messageDisplay = "success";
String patronBarcode = "3456784";
String toInstitution = "PUL";
String subject = "test";
Mockito.when(propertyUtil.getPropertyByInstitutionAndKey(any(), any())).thenReturn("[email protected]");
emailService.sendLASExceptionEmail(customerCode,itemBarcode,messageDisplay,patronBarcode,toInstitution,subject);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,37 @@ public void testValidForEddAvailableforOwnInst() throws Exception {
Map<String, String> frozenInstitutionMessagesPropertyMap = new HashMap<>();
frozenInstitutionMessagesPropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),"Test");
recallAvailablePropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),Boolean.TRUE.toString());
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRecapDeliveryRestrictionLikeEDD(any(), anyInt())).thenReturn(null);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_ENABLE_CIRCULATION_FREEZE)).thenReturn(frozenInstitutionPropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_RECALL_FUNCTIONALITY_AVAILABLE)).thenReturn(recallAvailablePropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_CIRCULATION_FREEZE_MESSAGE)).thenReturn(frozenInstitutionMessagesPropertyMap);
Mockito.when(institutionDetailsRepository.findByInstitutionCode(any())).thenReturn(getInstitutionEntity());
Mockito.when(imsLocationDetailsRepository.findById(any())).thenReturn(Optional.of(getImsLocationEntity()));
Mockito.when(itemController.findByBarcodeIn(itemBarcodes.toString())).thenReturn(Arrays.asList(itemEntity));
Mockito.when(requestItemDetailsRepository.findByItemBarcodeAndRequestStaCode(any(),anyString())).thenReturn(requestItemEntity);
ResponseEntity responseEntity6 = itemValidatorService.itemValidation(itemRequestInformation);
assertNotNull(responseEntity6);
}

@Test
public void testValidForValidateCustomerCode() throws Exception {
List<String> itemBarcodes = new ArrayList<>();
itemBarcodes.add("10123");
ItemRequestInformation itemRequestInformation = getItemRequestInformation(itemBarcodes);
itemRequestInformation.setRequestType(ScsbCommonConstants.REQUEST_TYPE_RECALL);
itemRequestInformation.setDeliveryLocation("PA");
ItemEntity itemEntity = getItemEntity();
RequestItemEntity requestItemEntity = getRequestItemEntity();
requestItemEntity.setId(0);
Map<String, String> frozenInstitutionPropertyMap = new HashMap<>();
Map<String, String> recallAvailablePropertyMap = new HashMap<>();
Map<String, String> frozenInstitutionMessagesPropertyMap = new HashMap<>();
frozenInstitutionMessagesPropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),"Test");
recallAvailablePropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),Boolean.TRUE.toString());
List<Object[]> deliveryCodeEntityList = new ArrayList<>();
Object[] deliveryCodeEntity = {getDeliveryCodeEntity()};
deliveryCodeEntityList.add(deliveryCodeEntity);
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRequestingInstitution(anyInt(), anyInt(), anyString())).thenReturn(deliveryCodeEntityList);
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRecapDeliveryRestrictionLikeEDD(any(), anyInt())).thenReturn(getOwnerCodeEntity());
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_ENABLE_CIRCULATION_FREEZE)).thenReturn(frozenInstitutionPropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_RECALL_FUNCTIONALITY_AVAILABLE)).thenReturn(recallAvailablePropertyMap);
Expand All @@ -481,6 +512,73 @@ public void testValidForEddAvailableforOwnInst() throws Exception {
Mockito.when(imsLocationDetailsRepository.findById(any())).thenReturn(Optional.of(getImsLocationEntity()));
Mockito.when(itemController.findByBarcodeIn(itemBarcodes.toString())).thenReturn(Arrays.asList(itemEntity));
Mockito.when(requestItemDetailsRepository.findByItemBarcodeAndRequestStaCode(any(),anyString())).thenReturn(requestItemEntity);
Mockito.when(deliveryCodeDetailsRepository.findByDeliveryCodeAndOwningInstitutionIdAndActive(any(), anyInt(), anyChar())).thenReturn(getDeliveryCodeEntity());
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndOwningInstitutionCode(any(), any())).thenReturn(getOwnerCodeEntity());
ResponseEntity responseEntity6 = itemValidatorService.itemValidation(itemRequestInformation);
assertNotNull(responseEntity6);
}

@Test
public void testValidForValidateCustomerCodeNull() throws Exception {
List<String> itemBarcodes = new ArrayList<>();
itemBarcodes.add("10123");
ItemRequestInformation itemRequestInformation = getItemRequestInformation(itemBarcodes);
itemRequestInformation.setRequestType(ScsbCommonConstants.REQUEST_TYPE_RECALL);
itemRequestInformation.setDeliveryLocation("PA");
ItemEntity itemEntity = getItemEntity();
RequestItemEntity requestItemEntity = getRequestItemEntity();
requestItemEntity.setId(0);
Map<String, String> frozenInstitutionPropertyMap = new HashMap<>();
Map<String, String> recallAvailablePropertyMap = new HashMap<>();
Map<String, String> frozenInstitutionMessagesPropertyMap = new HashMap<>();
frozenInstitutionMessagesPropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),"Test");
recallAvailablePropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),Boolean.TRUE.toString());
List<Object[]> deliveryCodeEntityList = new ArrayList<>();
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRequestingInstitution(anyInt(), anyInt(), anyString())).thenReturn(deliveryCodeEntityList);
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRecapDeliveryRestrictionLikeEDD(any(), anyInt())).thenReturn(getOwnerCodeEntity());
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_ENABLE_CIRCULATION_FREEZE)).thenReturn(frozenInstitutionPropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_RECALL_FUNCTIONALITY_AVAILABLE)).thenReturn(recallAvailablePropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_CIRCULATION_FREEZE_MESSAGE)).thenReturn(frozenInstitutionMessagesPropertyMap);
Mockito.when(institutionDetailsRepository.findByInstitutionCode(any())).thenReturn(getInstitutionEntity());
Mockito.when(imsLocationDetailsRepository.findById(any())).thenReturn(Optional.of(getImsLocationEntity()));
Mockito.when(itemController.findByBarcodeIn(itemBarcodes.toString())).thenReturn(Arrays.asList(itemEntity));
Mockito.when(requestItemDetailsRepository.findByItemBarcodeAndRequestStaCode(any(),anyString())).thenReturn(requestItemEntity);
Mockito.when(deliveryCodeDetailsRepository.findByDeliveryCodeAndOwningInstitutionIdAndActive(any(), anyInt(), anyChar())).thenReturn(getDeliveryCodeEntity());
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndOwningInstitutionCode(any(), any())).thenReturn(getOwnerCodeEntity());
ResponseEntity responseEntity6 = itemValidatorService.itemValidation(itemRequestInformation);
assertNotNull(responseEntity6);
}

@Test
public void testValidForValidateCustomerCodeTranslator() throws Exception {
List<String> itemBarcodes = new ArrayList<>();
itemBarcodes.add("10123");
ItemRequestInformation itemRequestInformation = getItemRequestInformation(itemBarcodes);
itemRequestInformation.setRequestType(ScsbCommonConstants.REQUEST_TYPE_RECALL);
itemRequestInformation.setDeliveryLocation("PA");
ItemEntity itemEntity = getItemEntity();
RequestItemEntity requestItemEntity = getRequestItemEntity();
requestItemEntity.setId(0);
Map<String, String> frozenInstitutionPropertyMap = new HashMap<>();
Map<String, String> recallAvailablePropertyMap = new HashMap<>();
Map<String, String> frozenInstitutionMessagesPropertyMap = new HashMap<>();
frozenInstitutionMessagesPropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),"Test");
recallAvailablePropertyMap.put(itemEntity.getInstitutionEntity().getInstitutionCode(),Boolean.TRUE.toString());
List<Object[]> deliveryCodeEntityList = new ArrayList<>();
Object[] deliveryCodeEntity = {getDeliveryCodeEntity()};
deliveryCodeEntityList.add(deliveryCodeEntity);
Mockito.when(deliveryCodeTranslationDetailsRepository.findByRequestingInstitutionandImsLocation(any(), any(), any())).thenReturn(getDeliveryCodeTranslationEntity());
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRequestingInstitution(anyInt(), anyInt(), anyString())).thenReturn(deliveryCodeEntityList);
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndRecapDeliveryRestrictionLikeEDD(any(), anyInt())).thenReturn(getOwnerCodeEntity());
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_ENABLE_CIRCULATION_FREEZE)).thenReturn(frozenInstitutionPropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_RECALL_FUNCTIONALITY_AVAILABLE)).thenReturn(recallAvailablePropertyMap);
Mockito.when(propertyUtil.getPropertyByKeyForAllInstitutions(PropertyKeyConstants.ILS.ILS_CIRCULATION_FREEZE_MESSAGE)).thenReturn(frozenInstitutionMessagesPropertyMap);
Mockito.when(institutionDetailsRepository.findByInstitutionCode(any())).thenReturn(getInstitutionEntity());
Mockito.when(imsLocationDetailsRepository.findById(any())).thenReturn(Optional.of(getImsLocationEntity()));
Mockito.when(itemController.findByBarcodeIn(itemBarcodes.toString())).thenReturn(Arrays.asList(itemEntity));
Mockito.when(requestItemDetailsRepository.findByItemBarcodeAndRequestStaCode(any(),anyString())).thenReturn(requestItemEntity);
Mockito.when(deliveryCodeDetailsRepository.findByDeliveryCodeAndOwningInstitutionIdAndActive(any(), anyInt(), anyChar())).thenReturn(getDeliveryCodeEntity());
Mockito.when(ownerCodeDetailsRepository.findByOwnerCodeAndOwningInstitutionCode(any(), any())).thenReturn(getOwnerCodeEntity());
ResponseEntity responseEntity6 = itemValidatorService.itemValidation(itemRequestInformation);
assertNotNull(responseEntity6);
}
Expand Down

0 comments on commit 8a02a52

Please sign in to comment.