File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,17 @@ void parseJsonMember(JsonObject.Member member) {
5858 this .sourceInfo = BoxResource .parseInfo (this .getAPI (), value .asObject ());
5959 break ;
6060 case "event_type" :
61- this .type = BoxEvent .Type .valueOf (value .asString ());
61+ String stringValue = value .asString ();
62+ for (Type t : Type .values ()) {
63+ if (t .name ().equals (stringValue )) {
64+ this .type = t ;
65+ break ;
66+ }
67+ }
68+
69+ if (this .type == null ) {
70+ this .type = Type .UNKNOWN ;
71+ }
6272 break ;
6373 default :
6474 break ;
@@ -69,6 +79,11 @@ void parseJsonMember(JsonObject.Member member) {
6979 * Enumerates the possible types for an event.
7080 */
7181 public enum Type {
82+ /**
83+ * The type of the event is unknown.
84+ */
85+ UNKNOWN ,
86+
7287 /**
7388 * An file or folder was created.
7489 */
Original file line number Diff line number Diff line change 1+ package com .box .sdk ;
2+
3+ import static org .hamcrest .Matchers .is ;
4+ import static org .junit .Assert .assertThat ;
5+
6+ import org .junit .Test ;
7+ import org .junit .experimental .categories .Category ;
8+
9+ public class BoxEventTest {
10+ @ Test
11+ @ Category (UnitTest .class )
12+ public void newBoxEventHandlesUnknownEventType () {
13+ String eventJSON = "{ \" type\" : \" event\" , \" event_id\" : \" f82c3ba03e41f7e8a7608363cc6c0390183c3f83\" , "
14+ + "\" event_type\" : \" UNKNOWN_EVENT_TYPE\" }" ;
15+ BoxEvent event = new BoxEvent (null , eventJSON );
16+
17+ assertThat (event .getType (), is (BoxEvent .Type .UNKNOWN ));
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments