我尝试了以下相同的错误:
我尝试了以下内容:
public interface InventorydetailQuery extends InventorydetailDAO {
public static final String GET_UNFIT_UNSORTED_INVENTORYDETAIL = "Inventorydetail.getInventorydetailUnfitUnsorted";
public static final String GET_UNASSIGNED_INVENTORYDETAIL_BY_DENOM_AND_SUBTYPE = "Inventorydetail.getUnassingedInventorydetailByDenomAndSubType";
public static final String GET_UNASSIGNED_INVENTORYDETAIL_BY_REEL = "Inventorydetail.getUnassingedInventorydetailByReel";
public static final String GET_UNFIT_INVENTORYDETAIL_BY_DENOM_AND_SUBTYPE = "Inventorydetail.getUnfitInventorydetailByDenomAndSubType";
public List<Inventorydetail> getUnfitUnsortedInventorydetail(
BigDecimal facevalue, String teamname, Integer fedofficekey);
public List<Inventorydetail> getUnassingedInventorydetailByDenomAndSubType (BigDecimal facevalue, String inventorySubType,
String inventoryType, String valuableType, Integer fedTeamKey);
public List<Inventorydetail> getUnfitInventorydetailByDenomAndSubType (BigDecimal facevalue, String inventorySubType,
String inventoryType, String valuableType, Integer fedTeamKey);
public List<Inventorydetail> getUnassingedInventorydetailByReel (BigDecimal facevalue, String inventorySubType,
String inventoryType, String valuableType, Integer fedTeamKey, Integer bpsreelkey);
}
@RunWith(MockitoJUnitRunner.class)
public class ServiceTest {
@Mock
private BPSReelQuery mockBPSReelQuery;
@Mock
private BpsreelDAOImpl reelDAO;
@Mock
private InventorydetailQuery mockInventorydetailQuery;
@Mock
private InventorydetailDAO mockInventorydetailDAO;
@Test
public void testgetBPSReels(){
when(mockBPSReelQuery.getBpsreelDetails(FED_TEAM_KEY, CURRENT_BUSINESS_DATE)).thenReturn(getBPSReelDetails());
List<ShiftReelImportedBean> shiftReelImportedBean = processReelsAutomaticModeService.getBPSReelDetails(FED_TEAM_KEY);
assertNotNull(shiftReelImportedBean);
verify(mockBPSReelQuery).getBpsreelDetails(FED_TEAM_KEY, CURRENT_BUSINESS_DATE);
}
@Test
public void testBalanceReel_Scenario1() {
ReelBalanceBean reelBalanceBean = createReelBalanceBean(VerificationConstants.RS_NORMAL, VerificationConstants.RS_FINISHED);
CPFirstRunBean cpFirstRunBean=new CPFirstRunBean();
RSNormalBean rsNormalBean=new RSNormalBean();
RecapBean recapBean = createRecapBean(BigDecimal.ZERO);
Bpsreel bpsReel = createBpsReel();
when(mockBPSReelQuery.store(bpsReel)).thenReturn(bpsReel);
when(mockBPSReelQuery.findBpsreelByPrimaryKey(any(Integer.class))).thenReturn(bpsReel);
List<Inventorydetail> inventoryDetailsList = createInventoryDetailsList();
when(mockInventorydetailQuery.getUnassingedInventorydetailByDenomAndSubType(reelBalanceBean.getFaceValue(),
VerificationConstants.INVENTORY_SUB_TYPE_UNSORTED, VerificationConstants.INVENTORY_TYPE_UNSORTED,
VerificationConstants.VALUABLE_TYPE_CURRENCY, FED_TEAM_KEY)).thenReturn(inventoryDetailsList);
verify(mockInventorydetailQuery).getUnassingedInventorydetailByDenomAndSubType(reelBalanceBean.getFaceValue(),
VerificationConstants.INVENTORY_SUB_TYPE_UNSORTED, VerificationConstants.INVENTORY_TYPE_UNSORTED,
VerificationConstants.VALUABLE_TYPE_CURRENCY, FED_TEAM_KEY);
}
}
仍然得到同样的例外。解决这个问题的任何提示都是贬值的。
谢谢,
MS
答案 0 :(得分:1)
目前还没有足够的答案。这是类似于我期望看到的东西。
Reel.java:
package org.makeyourcase;
public interface Reel {
}
ReelQuery.java:
package org.makeyourcase;
public interface ReelQuery {
void store(Reel reel);
}
ReelService.java:
package org.makeyourcase;
public class ReelService {
private ReelQuery reelQuery;
public void store(Reel reel) {
reelQuery.store(reel);
}
}
ReelQueryTest.java:
package org.makeyourcase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public class ReelServiceTest {
@Mock
private ReelQuery mockReelQuery;
@Mock
private Reel mockReel;
@InjectMocks
private ReelService subject;
@Test
public void testThat_Store_DelegatesToQuery() throws Exception {
subject.store(mockReel);
verify(mockReelQuery).store(mockReel);
}
}