TableDataInsertAllResponse toPb() { TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse(); if (!insertErrors.isEmpty()) { responsePb.setInsertErrors( ImmutableList.copyOf( Iterables.transform( insertErrors.entrySet(), new Function<Map.Entry<Long, List<BigQueryError>>, InsertErrors>() { @Override public InsertErrors apply(Map.Entry<Long, List<BigQueryError>> entry) { return new InsertErrors() .setIndex(entry.getKey()) .setErrors( Lists.transform(entry.getValue(), BigQueryError.TO_PB_FUNCTION)); } }))); } return responsePb; }
.setTemplateSuffix("suffix"); TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of(
.setTemplateSuffix("suffix"); TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of(
.setTemplateSuffix("suffix"); TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of(
TableDataInsertAllResponse toPb() { TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse(); if (!insertErrors.isEmpty()) { responsePb.setInsertErrors(ImmutableList.copyOf(Iterables.transform(insertErrors.entrySet(), new Function<Map.Entry<Long, List<BigQueryError>>, InsertErrors>() { @Override public InsertErrors apply(Map.Entry<Long, List<BigQueryError>> entry) { return new InsertErrors() .setIndex(entry.getKey()) .setErrors(Lists.transform(entry.getValue(), BigQueryError.TO_PB_FUNCTION)); } }))); } return responsePb; }
TableDataInsertAllResponse toPb() { TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse(); if (!insertErrors.isEmpty()) { responsePb.setInsertErrors(ImmutableList.copyOf(Iterables.transform(insertErrors.entrySet(), new Function<Map.Entry<Long, List<BigQueryError>>, InsertErrors>() { @Override public InsertErrors apply(Map.Entry<Long, List<BigQueryError>> entry) { return new InsertErrors() .setIndex(entry.getKey()) .setErrors(Lists.transform(entry.getValue(), BigQueryError.TO_PB_FUNCTION)); } }))); } return responsePb; }
TableDataInsertAllResponse toPb() { TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse(); if (!insertErrors.isEmpty()) { responsePb.setInsertErrors( ImmutableList.copyOf( Iterables.transform( insertErrors.entrySet(), new Function<Map.Entry<Long, List<BigQueryError>>, InsertErrors>() { @Override public InsertErrors apply(Map.Entry<Long, List<BigQueryError>> entry) { return new InsertErrors() .setIndex(entry.getKey()) .setErrors( Lists.transform(entry.getValue(), BigQueryError.TO_PB_FUNCTION)); } }))); } return responsePb; }
private void onInsertAll(List<List<Long>> errorIndicesSequence) throws Exception { when(mockClient.tabledata()).thenReturn(mockTabledata); final List<TableDataInsertAllResponse> responses = new ArrayList<>(); for (List<Long> errorIndices : errorIndicesSequence) { List<TableDataInsertAllResponse.InsertErrors> errors = new ArrayList<>(); for (long i : errorIndices) { TableDataInsertAllResponse.InsertErrors error = new TableDataInsertAllResponse.InsertErrors(); error.setIndex(i); } TableDataInsertAllResponse response = new TableDataInsertAllResponse(); response.setInsertErrors(errors); responses.add(response); } doAnswer( invocation -> { Bigquery.Tabledata.InsertAll mockInsertAll = mock(Bigquery.Tabledata.InsertAll.class); when(mockInsertAll.execute()) .thenReturn( responses.get(0), responses .subList(1, responses.size()) .toArray(new TableDataInsertAllResponse[responses.size() - 1])); return mockInsertAll; }) .when(mockTabledata) .insertAll(anyString(), anyString(), anyString(), any(TableDataInsertAllRequest.class)); }
when(response.getContent()) .thenReturn(toStream(errorWithReasonAndStatus("rateLimitExceeded", 403))) .thenReturn(toStream(new TableDataInsertAllResponse()));
new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of( new InsertErrors().setIndex(1L).setErrors(ImmutableList.of(new ErrorProto())))); final TableDataInsertAllResponse allRowsSucceeded = new TableDataInsertAllResponse();
when(response.getContent()) .thenReturn(toStream(errorWithReasonAndStatus("actually forbidden", 403))) .thenReturn(toStream(new TableDataInsertAllResponse()));
new TableDataInsertAllResponse() .setInsertErrors(ImmutableList.of(new InsertErrors().setIndex(1L))); new TableDataInsertAllResponse() .setInsertErrors(ImmutableList.of(new InsertErrors().setIndex(0L)));
new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of( new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of( final TableDataInsertAllResponse allRowsSucceeded = new TableDataInsertAllResponse();
new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of(
new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of(
ImmutableList.of(wrapValue(new TableRow()), wrapValue(new TableRow())); final TableDataInsertAllResponse allRowsSucceeded = new TableDataInsertAllResponse();