Skip to content

Commit

Permalink
Add test case for NPE on SourceTask::commit
Browse files Browse the repository at this point in the history
  • Loading branch information
castorm committed Dec 26, 2020
1 parent a8751e8 commit d334ded
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -110,6 +110,16 @@ private static SourceTaskContext getContext(Map<String, Object> offset) {
return context;
}

@Test
void givenTaskNotPolled_whenCommit_thenNoException() {

givenTaskConfiguration();
task.initialize(getContext(emptyMap()));
task.start(emptyMap());

task.commit();
}

@Test
void givenTaskInitializedWithRestoredOffset_whenStart_thenLastOffsetIsRestored() {

Expand Down Expand Up @@ -247,7 +257,7 @@ void givenTaskStarted_whenPollAndCommitRecords_thenOffsetUpdated() throws Interr
given(client.execute(request)).willReturn(response);
given(responseParser.parse(response)).willReturn(asList(record(offsetMap)));
given(recordSorter.sort(asList(record(offsetMap))))
.willReturn(asList(record(offsetMap(1)), record(offsetMap(2)), record(offsetMap(3))));
.willReturn(asList(record(offsetMap(1)), record(offsetMap(2)), record(offsetMap(3))));
given(recordFilterFactory.create(offset)).willReturn(__ -> true);
task.poll();

Expand Down

0 comments on commit d334ded

Please sign in to comment.