ImmutableList.of( new TableDataInsertAllResponse.InsertErrors() .setIndex(0L) .setErrors(ImmutableList.of(new ErrorProto().setMessage("ErrorMessage"))))); EasyMock.expect(bigqueryRpcMock.insertAll(OTHER_PROJECT, DATASET, TABLE, requestPb))
ImmutableList.of( new TableDataInsertAllResponse.InsertErrors() .setIndex(0L) .setErrors(ImmutableList.of(new ErrorProto().setMessage("ErrorMessage"))))); EasyMock.expect(
ImmutableList.of( new TableDataInsertAllResponse.InsertErrors() .setIndex(0L) .setErrors(ImmutableList.of(new ErrorProto().setMessage("ErrorMessage"))))); EasyMock.expect(bigqueryRpcMock.insertAll(PROJECT, DATASET, TABLE, requestPb))
ImmutableList.of( new InsertErrors() .setIndex(0L) .setErrors(ImmutableList.of(new ErrorProto().setReason("timeout"))), new InsertErrors() .setIndex(1L) .setErrors(ImmutableList.of(new ErrorProto().setReason("invalid"))))); ImmutableList.of( new InsertErrors() .setIndex(0L) .setErrors(ImmutableList.of(new ErrorProto().setReason("timeout")))));
.setInsertErrors( ImmutableList.of( new InsertErrors().setIndex(1L).setErrors(ImmutableList.of(new ErrorProto()))));
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)); }
@Test public void testDecodeEncodeEqual() throws Exception { BigQueryInsertError value = new BigQueryInsertError( new TableRow().setF(Collections.singletonList(new TableCell().setV("Value"))), new TableDataInsertAllResponse.InsertErrors() .setIndex(0L) .setErrors( Collections.singletonList( new ErrorProto() .setReason("a Reason") .setLocation("A location") .setMessage("A message") .setDebugInfo("The debug info"))), new TableReference() .setProjectId("dummy-project-id") .setDatasetId("dummy-dataset-id") .setTableId("dummy-table-id")); CoderProperties.coderDecodeEncodeEqual(TEST_CODER, value); } }