File tree Expand file tree Collapse file tree
main/java/com/google/gcloud/bigquery
test/java/com/google/gcloud/bigquery Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package com .google .gcloud .bigquery ;
1818
19+ import static com .google .common .base .Preconditions .checkNotNull ;
20+
1921import com .google .api .services .bigquery .model .Dataset .Access ;
2022
2123import java .io .Serializable ;
@@ -370,15 +372,15 @@ Access toPb() {
370372 * Build an ACL for an {@code entity} and a {@code role}.
371373 */
372374 public Acl (Entity entity , Role role ) {
373- this .entity = entity ;
375+ this .entity = checkNotNull ( entity ) ;
374376 this .role = role ;
375377 }
376378
377379 /**
378380 * Build an ACL for a view entity.
379381 */
380382 public Acl (View view ) {
381- this .entity = view ;
383+ this .entity = checkNotNull ( view ) ;
382384 this .role = null ;
383385 }
384386
@@ -428,7 +430,7 @@ Access toPb() {
428430 }
429431
430432 static Acl fromPb (Access access ) {
431- Role role = Role . valueOf ( access . getRole ());
432- return new Acl ( Entity . fromPb (access ), role );
433+ return new Acl ( Entity . fromPb ( access ),
434+ access . getRole () != null ? Role . valueOf (access . getRole ()) : null );
433435 }
434436}
Original file line number Diff line number Diff line change @@ -87,5 +87,9 @@ public void testAcl() {
8787 assertEquals (Role .READER , acl .role ());
8888 Dataset .Access pb = acl .toPb ();
8989 assertEquals (acl , Acl .fromPb (pb ));
90+ View view = new View (TableId .of ("project" , "dataset" , "view" ));
91+ acl = new Acl (view );
92+ assertEquals (view , acl .entity ());
93+ assertEquals (null , acl .role ());
9094 }
9195}
You can’t perform that action at this time.
0 commit comments