我试图返回响应对象,让程序使用响应对象的一些属性。 我正在使用MockitoJUnitRunner.class并模拟了notificationService类。
我将对象作为空对象。我需要它作为我返回的具有属性的对象。
Request request = new Request();
Element element = new Element("element");
element.addContent(new Element("solnbr").setText("AWARD"));
request.setData(element);
SystemAccountResponse systemAccountResponse = new SystemAccountResponse();
MultiValueMap<String, String> searchParams = new LinkedMultiValueMap<>();
searchParams.add("solNumber","AWARD");
OpportunityRESTResponse response = new OpportunityRESTResponse();
Embedded embedded = new Embedded();
List<Opportunity> opportunityList = new ArrayList<>();
Opportunity opportunity = new Opportunity();
opportunity.setId("1");
opportunityList.add(0, opportunity);
embedded.setOpportunity(opportunityList);
response.setEmbedded(embedded);
Page page = new Page();
page.setTotalElements(10);
response.setPage(page);
when(opportunityRestService.getNoticeList(searchParams, systemAccountResponse)).thenReturn(response);
notificationService.getNoticeListResponse(request);