Skip to content

Commit

Permalink
Makes publishing status and steps visible in BatchItemResponse.
Browse files Browse the repository at this point in the history
For #264.
  • Loading branch information
dehora committed Sep 21, 2017
1 parent 40c801a commit f147bcd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
16 changes: 14 additions & 2 deletions nakadi-java-client/src/main/java/nakadi/BatchItemResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public PublishingStatus publishingStatus() {
return publishing_status;
}

@VisibleForTesting
BatchItemResponse publishingStatus(PublishingStatus publishingStatus) {
this.publishing_status = publishingStatus;
return this;
}

@VisibleForTesting
BatchItemResponse step(Step step) {
this.step = step;
return this;
}

public Step step() {
return step;
}
Expand Down Expand Up @@ -47,11 +59,11 @@ public String detail() {
'}';
}

enum PublishingStatus {
public enum PublishingStatus {
failed, submitted, aborted
}

enum Step {
public enum Step {
none, validating, partitioning, enriching, publishing
}
}
21 changes: 21 additions & 0 deletions nakadi-java-client/src/test/java/nakadi/BatchItemResponseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package nakadi;

import org.junit.Test;

import static org.junit.Assert.*;

public class BatchItemResponseTest {


@Test
public void statusStep() {

BatchItemResponse bir = new BatchItemResponse();
bir.publishingStatus(BatchItemResponse.PublishingStatus.failed);
bir.step(BatchItemResponse.Step.partitioning);

assertEquals(bir.publishingStatus(), BatchItemResponse.PublishingStatus.failed);
assertEquals(bir.step(), BatchItemResponse.Step.partitioning);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package nakadi.test;

import java.util.EnumSet;
import nakadi.BatchItemResponse;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class BatchItemResponseVisibilityTest {


@Test
public void visibility_gh264() {
// https://github.com/dehora/nakadi-java/issues/264
EnumSet<BatchItemResponse.PublishingStatus> errors = EnumSet.of(
BatchItemResponse.PublishingStatus.failed,
BatchItemResponse.PublishingStatus.aborted
);

assertTrue(errors.size() == 2);
}

}

0 comments on commit f147bcd

Please sign in to comment.