Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main/java/org/kohsuke/github/GHMilestone.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.kohsuke.github;

import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.github.internal.EnumUtils;

import java.io.IOException;
import java.net.URL;
import java.time.Instant;
import java.util.Date;
import java.util.Locale;

// TODO: Auto-generated Javadoc
/**
Expand Down Expand Up @@ -141,10 +142,11 @@ public GHRepository getOwner() {
/**
* Gets state.
*
* @return the state
* @return the state, or {@code null} if the state is not available
*/
@CheckForNull
public GHMilestoneState getState() {
return Enum.valueOf(GHMilestoneState.class, state.toUpperCase(Locale.ENGLISH));
return EnumUtils.getNullableEnumOrDefault(GHMilestoneState.class, state, GHMilestoneState.UNKNOWN);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/kohsuke/github/GHMilestoneState.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ public enum GHMilestoneState {
/** The closed. */
CLOSED,
/** The open. */
OPEN
OPEN,
/** The unknown. */
UNKNOWN
}
2 changes: 1 addition & 1 deletion src/test/java/org/kohsuke/github/EnumTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void touchEnums() {

assertThat(GHMembership.Role.values().length, equalTo(2));

assertThat(GHMilestoneState.values().length, equalTo(2));
assertThat(GHMilestoneState.values().length, equalTo(3));

assertThat(GHMyself.RepositoryListFilter.values().length, equalTo(5));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static java.util.stream.Collectors.toList;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;

// TODO: Auto-generated Javadoc
/**
Expand All @@ -24,7 +25,10 @@ public class GHIssueEventAttributeTest extends AbstractGitHubWireMockTest {
private enum Type implements Predicate<GHIssueEvent>, Consumer<GHIssueEvent> {
assignment(e -> assertThat(e.getAssignee(), notNullValue()), "assigned", "unassigned"),
label(e -> assertThat(e.getLabel(), notNullValue()), "labeled", "unlabeled"),
milestone(e -> assertThat(e.getMilestone(), notNullValue()), "milestoned", "demilestoned");
milestone(e -> {
assertThat(e.getMilestone(), notNullValue());
assertThat(e.getMilestone().getState(), nullValue());
}, "milestoned", "demilestoned");

private final Consumer<GHIssueEvent> assertion;
private final Set<String> subtypes;
Expand Down
Loading