Исключение MockMvc PostRequest - PullRequest
0 голосов
/ 08 ноября 2018

У меня есть следующий пост картирования.

@PostMapping(value = BULK_UPDATE)
@ApiOperation(value = "Bulk Update of Markets by pairs of Market Key and Tier Quantity Id", tags = "Bulk", code = 200)
@ApiImplicitParams({
        @ApiImplicitParam(name = "MarketTierQuantityId", value = "List of Market Key and Tier Quantity Id pairs",
                paramType = "body", allowMultiple = true, dataType = "MarketTierQuantityId", required = true) })
@ApiResponses({
        @ApiResponse(code = 200, message = "Bulk update successful", response = MarketStatus.class, responseContainer = "List") })
@ResponseStatus(org.springframework.http.HttpStatus.OK)
public ResponseEntity<StreamingResponseBody> bulkUpdate(
        @RequestParam(name = IGNORE_SYNC_PAUSE_FAILURE, required = false, defaultValue = "false")
        @ApiParam(name = IGNORE_SYNC_PAUSE_FAILURE, value = "Ignore failure of the jobs pause command") boolean ignoreJobsPauseFailure,
        @RequestBody @ApiParam(name = "MarketTierQuantityId", value = "List of Market Key and Tier Quantity Id pairs", required = true) List<MarketTierQuantityId> marketTierQuantities,
        @RequestParam(name = MOVE_TO_PREAUTH_FLAG, required = false, defaultValue = "true")
        @ApiParam(name = MOVE_TO_PREAUTH_FLAG, value = "Move new units to Preauth for the markets with active waitlists") boolean moveToPreauth) throws BusinessException {
    String requestId = getRequestId();
    boolean jobsPaused = pauseJobs(ignoreJobsPauseFailure);

    return LoggingStopWatch.wrap(() -> {
        return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON)
                .body(outputStream -> process(new SyncBulkProcessorHelper(outputStream),
                        marketTierQuantities, jobsPaused, requestId, moveToPreauth, LoggingStopWatch.create(LOGGER, "Bulk Update")));
    });
}

и я написал следующий тест.

@RunWith(SpringRunner.class)
@WebMvcTest(BulkUpdateController.class)
@ContextConfiguration(classes = { BulkUpdateController.class, SharedExecutor.class })
@ActiveProfiles("dev")
public class BulkUpdateControllerTest {

    @Autowired
    private MockMvc mockMvc;

    @MockBean
    private BulkStatusService bulkStatusService;

    @MockBean
    private BulkMarketService bulkMarketService;

    @MockBean
    private HttpService httpService;

    @MockBean
    private RestClient restClient;

    @MockBean
    private BulkProcessorHelper helper;


    @Test
    public void test() throws Exception {
        String request = TestHelper.getSerializedRequest(getBulkUpdateRequest(), MarketTierQuantityId.class);
        mockMvc.perform(post("/bulkupdate").accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON)
                .content(request)).andExpect(status().is4xxClientError());
    }


    public MarketTierQuantityId getBulkUpdateRequest() {
        MarketTierQuantityId market = new MarketTierQuantityId();
        market.setMarketKey("00601|PR|COBROKE|POSTALCODE|FULL");
        market.setTierQuantityId("10");
        return market;
    }

Получив следующую ошибку, перепробовал все возможные способы ее устранения, но это не помогло.

Запрос не выполнен. Ответ об ошибке: {\ "ResponseStatus \": {\ "ERRORCODE \": \ "BadRequest \", \ "сообщение \": \ "JSON ошибка синтаксического анализа: не удалось десериализовать экземпляр java.util.ArrayList out маркера START_OBJECT \ ", \" stackTrace \ ": \" BusinessException (синтаксический анализ JSON) Ошибка:

P.S -> новичок в Юнитах и ​​издевательствах

...