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 responsePb = new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of( new TableDataInsertAllResponse.InsertErrors()
TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of( new TableDataInsertAllResponse.InsertErrors()
TableDataInsertAllResponse responsePb = new TableDataInsertAllResponse() .setInsertErrors( ImmutableList.of( new TableDataInsertAllResponse.InsertErrors()
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)); }
.setInsertErrors(ImmutableList.of(new InsertErrors().setIndex(1L))); .setInsertErrors(ImmutableList.of(new InsertErrors().setIndex(0L)));
.setInsertErrors( ImmutableList.of( new InsertErrors().setIndex(1L).setErrors(ImmutableList.of(new ErrorProto()))));
.setInsertErrors( ImmutableList.of( new InsertErrors() .setInsertErrors( ImmutableList.of( new InsertErrors()
.setInsertErrors( ImmutableList.of( new InsertErrors()
.setInsertErrors( ImmutableList.of( new InsertErrors()