Merge branch 'stable-2.12' into stable-2.13

* stable-2.12:
  Change copyright to AOSP

Change-Id: I4a7eb3007befa0c83537f6d24529f3f416a25acf
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
index 629181b..950a90d 100644
--- a/lib/gerrit/BUCK
+++ b/lib/gerrit/BUCK
@@ -1,12 +1,12 @@
 include_defs('//bucklets/maven_jar.bucklet')
 
-VER = '2.12'
+VER = '2.13'
 REPO = MAVEN_CENTRAL
 
 maven_jar(
   name = 'plugin-api',
   id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
-  sha1 = '8ce1f6e65078bbcf03a1758f96b3ebca19b7fe3c',
+  sha1 = 'e25d55b8f41627c4ae6b9d2069ec398638b219a3',
   license = 'Apache2.0',
   attach_source = False,
   repository = REPO,
@@ -14,7 +14,7 @@
 maven_jar(
   name = 'acceptance-framework',
   id = 'com.google.gerrit:gerrit-acceptance-framework:' + VER,
-  sha1 = 'f35140148294239012b1a5052181783c0c9f4ffd',
+  sha1 = 'a6913a61196a8fccdb45e761f43a0b7e21867c90',
   license = 'Apache2.0',
   attach_source = False,
   repository = REPO,
diff --git a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java
index 6022a04..d11afca 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidator.java
@@ -37,6 +37,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+
 @Singleton
 public class ProjectCreationValidator
     implements ProjectCreationValidationListener {
@@ -127,7 +129,7 @@
             .apply(TopLevelResource.INSTANCE, new GroupInput());
       }
       return AccountGroup.UUID.parse(groupInfo.id);
-    } catch (RestApiException | OrmException e) {
+    } catch (RestApiException | OrmException | IOException e ) {
       log.error("Failed to create project " + name + ": " + e.getMessage(), e);
       throw new ValidationException(AN_ERROR_OCCURRED_MSG);
     }
diff --git a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorTest.java b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorTest.java
index d305210..b61f1aa 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorTest.java
@@ -30,13 +30,10 @@
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.project.ProjectState;
 
-import org.apache.http.HttpStatus;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import java.io.IOException;
-
 @Ignore
 public class ProjectCreationValidatorTest extends PluginDaemonTest {
 
@@ -49,14 +46,14 @@
   }
 
   @Test
-  public void shouldAllowAnyUsersToCreateUnderAllProjects() throws IOException {
+  public void shouldAllowAnyUsersToCreateUnderAllProjects() throws Exception {
     ProjectInput in = new ProjectInput();
     in.permissionsOnly = true;
-    assertThat(adminSession.put("/projects/" + name("someProject"), in)
-        .getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
+    adminRestSession.put("/projects/" + name("someProject"), in)
+        .assertCreated();
 
-    assertThat(userSession.put("/projects/" + name("someOtherProject"), in)
-        .getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
+    userRestSession.put("/projects/" + name("someOtherProject"), in)
+        .assertCreated();
   }
 
   @Test
@@ -65,13 +62,12 @@
     String parent = name("parentProject");
     ProjectInput in = new ProjectInput();
     in.permissionsOnly = true;
-    assertThat(userSession.put("/projects/" + parent, in).getStatusCode())
-        .isEqualTo(HttpStatus.SC_CREATED);
+    userRestSession.put("/projects/" + parent, in).assertCreated();
 
     // Creation is rejected when root project name contains slashes
     RestResponse r =
-        userSession.put("/projects/" + Url.encode("a/parentProject"), in);
-    assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
+        userRestSession.put("/projects/" + Url.encode("a/parentProject"), in);
+    r.assertConflict();
     assertThat(r.getEntityContent())
         .contains("Root project name cannot contains slashes");
   }
@@ -83,34 +79,32 @@
     ProjectInput in = new ProjectInput();
     in.permissionsOnly = true;
     String parent = name("parentProject");
-    assertThat(userSession.put("/projects/" + parent, in).getStatusCode())
-        .isEqualTo(HttpStatus.SC_CREATED);
+    userRestSession.put("/projects/" + parent, in).assertCreated();
 
     // Creation is rejected when project name does not start with parent
     in = new ProjectInput();
     in.parent = parent;
-    RestResponse r = userSession.put("/projects/childProject", in);
-    assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
+    RestResponse r = userRestSession.put("/projects/childProject", in);
+    r.assertConflict();
     assertThat(r.getEntityContent())
         .contains("Project name must start with parent project name");
 
     // Creation is OK when project name starts with parent
-    assertThat(
-        userSession.put("/projects/" + Url.encode(parent + "/childProject"), in)
-            .getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
+    userRestSession.put("/projects/" + Url.encode(parent + "/childProject"), in)
+        .assertCreated();
 
     // Creation is rejected when project name does not start with nested parent
     String nestedParent = parent + "/childProject";
     in.parent = nestedParent;
-    r = userSession.put("/projects/grandchild", in);
-    assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
+    r = userRestSession.put("/projects/grandchild", in);
+    r.assertConflict();
     assertThat(r.getEntityContent())
         .contains("Project name must start with parent project name");
 
     // Creation is OK when project name starts with nested parent
-    assertThat(userSession
+    userRestSession
         .put("/projects/" + Url.encode(nestedParent + "/grandchild"), in)
-        .getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
+        .assertCreated();
   }
 
   @Test
@@ -122,41 +116,36 @@
     ProjectInput in = new ProjectInput();
     in.permissionsOnly = true;
     in.owners = Lists.newArrayList(ownerGroup);
-    assertThat(adminSession.put("/projects/" + parent, in).getStatusCode())
-        .isEqualTo(HttpStatus.SC_CREATED);
+    adminRestSession.put("/projects/" + parent, in).assertCreated();
 
     // Creation is rejected when user is not owner of parent
     in = new ProjectInput();
     in.parent = parent;
-    RestResponse r = userSession
+    RestResponse r = userRestSession
         .put("/projects/" + Url.encode(parent + "/childProject"), in);
-    assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
+    r.assertConflict();
     assertThat(r.getEntityContent())
         .contains("You must be owner of the parent project");
 
     // Creation is OK when user is owner of parent
     g.addMembers(user.username);
-    assertThat(
-        userSession.put("/projects/" + Url.encode(parent + "/childProject"), in)
-            .getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
+    userRestSession.put("/projects/" + Url.encode(parent + "/childProject"), in)
+        .assertCreated();
   }
 
   @Test
-  public void shouldAllowAdminsToByPassAnyRule() throws IOException {
+  public void shouldAllowAdminsToByPassAnyRule() throws Exception {
     // Root project with a slash
     String parent = name("orgA/parentProject");
     ProjectInput in = new ProjectInput();
     in.permissionsOnly = true;
-    assertThat(
-        adminSession.put("/projects/" + Url.encode(parent), in).getStatusCode())
-            .isEqualTo(HttpStatus.SC_CREATED);
+    adminRestSession.put("/projects/" + Url.encode(parent), in).assertCreated();
 
     // Child project without name of parent as prefix
     in = new ProjectInput();
     in.parent = parent;
-    assertThat(
-        adminSession.put("/projects/" + Url.encode("orgA/childProject"), in)
-            .getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
+    adminRestSession.put("/projects/" + Url.encode("orgA/childProject"), in)
+        .assertCreated();
   }
 
   @Test
@@ -165,8 +154,7 @@
     String rootProject = name("rootProject");
     ProjectInput in = new ProjectInput();
     in.permissionsOnly = true;
-    assertThat(userSession.put("/projects/" + rootProject, in).getStatusCode())
-        .isEqualTo(HttpStatus.SC_CREATED);
+    userRestSession.put("/projects/" + rootProject, in).assertCreated();
     ProjectState projectState =
         projectCache.get(new Project.NameKey(rootProject));
     assertThat(projectState.getOwners().size()).isEqualTo(1);
@@ -177,8 +165,7 @@
     rootProject = name("rootProject2");
     String existingGroupName = rootProject + "-admins";
     gApi.groups().create(existingGroupName);
-    assertThat(userSession.put("/projects/" + rootProject, in).getStatusCode())
-        .isEqualTo(HttpStatus.SC_CREATED);
+    userRestSession.put("/projects/" + rootProject, in).assertCreated();
     projectState = projectCache.get(new Project.NameKey(rootProject));
     assertThat(projectState.getOwners().size()).isEqualTo(1);
     String expectedOwnerGroup = existingGroupName + "-"
@@ -190,8 +177,8 @@
 
   @Test
   public void shouldBlockRootCodeProject() throws Exception {
-    RestResponse r = userSession.put("/projects/" + Url.encode("project1"));
-    assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
+    RestResponse r = userRestSession.put("/projects/" + Url.encode("project1"));
+    r.assertConflict();
     assertThat(r.getEntityContent())
         .contains("Regular projects are not allowed as root");
   }