File tree Expand file tree Collapse file tree
branches/tswast-patch-1/gcloud-java-bigquery/src
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 @@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60- refs/heads/tswast-patch-1: dea8effe8e4b2011dc87507d4d391081b3d4b37d
60+ refs/heads/tswast-patch-1: 3f0d511746b9589de453dfce2a1171ff9ba301ad
6161refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b
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