Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Upgrade mockito-core to 2.28.2
  Add unit tests for oauth api providers

Change-Id: Ibdeda2a429697eb73e84aa7badb9fd632d38b9b6
diff --git a/BUILD b/BUILD
index c3d6504..b5d591b 100644
--- a/BUILD
+++ b/BUILD
@@ -32,6 +32,7 @@
     tags = ["oauth"],
     deps = [
         ":oauth__plugin_test_deps",
+        "@scribejava-core//jar",
     ],
 )
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/AirVantageApi.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/AirVantageApi.java
index 2e769a5..0426162 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/AirVantageApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/AirVantageApi.java
@@ -15,9 +15,6 @@
 package com.googlesource.gerrit.plugins.oauth;
 
 import com.github.scribejava.core.builder.api.DefaultApi20;
-import com.github.scribejava.core.extractors.OAuth2AccessTokenExtractor;
-import com.github.scribejava.core.extractors.TokenExtractor;
-import com.github.scribejava.core.model.OAuth2AccessToken;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignature;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignatureURIQueryParameter;
 
@@ -36,9 +33,4 @@
   public BearerSignature getBearerSignature() {
     return BearerSignatureURIQueryParameter.instance();
   }
-
-  @Override
-  public TokenExtractor<OAuth2AccessToken> getAccessTokenExtractor() {
-    return OAuth2AccessTokenExtractor.instance();
-  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java
index a68ae4b..06e92bc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/BitbucketApi.java
@@ -15,9 +15,6 @@
 package com.googlesource.gerrit.plugins.oauth;
 
 import com.github.scribejava.core.builder.api.DefaultApi20;
-import com.github.scribejava.core.extractors.OAuth2AccessTokenExtractor;
-import com.github.scribejava.core.extractors.TokenExtractor;
-import com.github.scribejava.core.model.OAuth2AccessToken;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignature;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignatureURIQueryParameter;
 
@@ -36,9 +33,4 @@
   public BearerSignature getBearerSignature() {
     return BearerSignatureURIQueryParameter.instance();
   }
-
-  @Override
-  public TokenExtractor<OAuth2AccessToken> getAccessTokenExtractor() {
-    return OAuth2AccessTokenExtractor.instance();
-  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/DexApi.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/DexApi.java
index 560aed7..1f2510e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/DexApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/DexApi.java
@@ -15,9 +15,6 @@
 package com.googlesource.gerrit.plugins.oauth;
 
 import com.github.scribejava.core.builder.api.DefaultApi20;
-import com.github.scribejava.core.extractors.OAuth2AccessTokenExtractor;
-import com.github.scribejava.core.extractors.TokenExtractor;
-import com.github.scribejava.core.model.OAuth2AccessToken;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignature;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignatureURIQueryParameter;
 
@@ -45,9 +42,4 @@
   public BearerSignature getBearerSignature() {
     return BearerSignatureURIQueryParameter.instance();
   }
-
-  @Override
-  public TokenExtractor<OAuth2AccessToken> getAccessTokenExtractor() {
-    return OAuth2AccessTokenExtractor.instance();
-  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/KeycloakApi.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/KeycloakApi.java
index 10482da..21e0749 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/KeycloakApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/KeycloakApi.java
@@ -15,9 +15,6 @@
 package com.googlesource.gerrit.plugins.oauth;
 
 import com.github.scribejava.core.builder.api.DefaultApi20;
-import com.github.scribejava.core.extractors.OAuth2AccessTokenExtractor;
-import com.github.scribejava.core.extractors.TokenExtractor;
-import com.github.scribejava.core.model.OAuth2AccessToken;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignature;
 import com.github.scribejava.core.oauth2.bearersignature.BearerSignatureURIQueryParameter;
 import com.github.scribejava.core.oauth2.clientauthentication.ClientAuthentication;
@@ -46,11 +43,6 @@
   }
 
   @Override
-  public TokenExtractor<OAuth2AccessToken> getAccessTokenExtractor() {
-    return OAuth2AccessTokenExtractor.instance();
-  }
-
-  @Override
   public BearerSignature getBearerSignature() {
     return BearerSignatureURIQueryParameter.instance();
   }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/AirVantageApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/AirVantageApiTest.java
new file mode 100644
index 0000000..9f2f3b3
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/AirVantageApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AirVantageApiTest {
+  private AirVantageApi api;
+
+  @Before
+  public void setUp() {
+    api = new AirVantageApi();
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/BitbucketApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/BitbucketApiTest.java
new file mode 100644
index 0000000..44eb198
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/BitbucketApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class BitbucketApiTest {
+  private BitbucketApi api;
+
+  @Before
+  public void setUp() {
+    api = new BitbucketApi();
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/CasApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/CasApiTest.java
new file mode 100644
index 0000000..17d0ca3
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/CasApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CasApiTest {
+  private CasApi api;
+
+  @Before
+  public void setUp() {
+    api = new CasApi("");
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/DexApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/DexApiTest.java
new file mode 100644
index 0000000..160e20c
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/DexApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DexApiTest {
+  private DexApi api;
+
+  @Before
+  public void setUp() {
+    api = new DexApi("");
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/Facebook2ApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/Facebook2ApiTest.java
new file mode 100644
index 0000000..b8afae5
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/Facebook2ApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class Facebook2ApiTest {
+  private Facebook2Api api;
+
+  @Before
+  public void setUp() {
+    api = new Facebook2Api();
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/GitHub2ApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/GitHub2ApiTest.java
new file mode 100644
index 0000000..6b29c59
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/GitHub2ApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GitHub2ApiTest {
+  private GitHub2Api api;
+
+  @Before
+  public void setUp() {
+    api = new GitHub2Api(GitHubOAuthService.GITHUB_ROOT_URL);
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/GitLabApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/GitLabApiTest.java
new file mode 100644
index 0000000..86b1c63
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/GitLabApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GitLabApiTest {
+  private GitLabApi api;
+
+  @Before
+  public void setUp() {
+    api = new GitLabApi("");
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/Google2ApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/Google2ApiTest.java
new file mode 100644
index 0000000..72ddaf3
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/Google2ApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class Google2ApiTest {
+  private Google2Api api;
+
+  @Before
+  public void setUp() {
+    api = new Google2Api();
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/KeycloakApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/KeycloakApiTest.java
new file mode 100644
index 0000000..cb0806d
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/KeycloakApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class KeycloakApiTest {
+  private KeycloakApi api;
+
+  @Before
+  public void setUp() {
+    api = new KeycloakApi("", "");
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/oauth/Office365ApiTest.java b/src/test/java/com/googlesource/gerrit/plugins/oauth/Office365ApiTest.java
new file mode 100644
index 0000000..6bcf313
--- /dev/null
+++ b/src/test/java/com/googlesource/gerrit/plugins/oauth/Office365ApiTest.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.oauth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.github.scribejava.core.extractors.OAuth2AccessTokenJsonExtractor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class Office365ApiTest {
+  private Office365Api api;
+
+  @Before
+  public void setUp() {
+    api = new Office365Api();
+  }
+
+  @Test
+  public void testAccessTokenExtractor() {
+    assertThat(api.getAccessTokenExtractor()).isInstanceOf(OAuth2AccessTokenJsonExtractor.class);
+  }
+}