// 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.google.gerrit.acceptance.rest.change;

import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;

import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.extensions.client.ArchiveFormat;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import org.junit.Test;

public class GetArchiveIT extends AbstractDaemonTest {
  @Test
  public void zipFormatIsDisabled() throws Exception {
    String changeId = createChange().getChangeId();
    MethodNotAllowedException ex =
        assertThrows(
            MethodNotAllowedException.class,
            () -> gApi.changes().id(changeId).current().getArchive(ArchiveFormat.ZIP));
    assertThat(ex).hasMessageThat().isEqualTo("zip format is disabled");
  }
}

@@ -886,24 +886,89 @@
 hiveFormat;%0A
+import com.google.gerrit.extensions.restapi.BadRequestException;%0A
 import com.g
@@ -1022,24 +1022,49 @@
 dException;%0A
+import org.junit.Before;%0A
 import org.j
@@ -1130,16 +1130,145 @@
 nTest %7B%0A
+  private String changeId;%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A    changeId = createChange().getChangeId();%0A  %7D%0A%0A
   @Test%0A
@@ -1285,25 +1285,24 @@
 oid 
-zipF
+f
 ormat
-IsDisabl
+NotSpecifi
 ed()
@@ -1329,55 +1329,310 @@
     
-String changeId = createChange().getChangeId();
+BadRequestException ex =%0A        assertThrows(%0A            BadRequestException.class,%0A            () -%3E gApi.changes().id(changeId).current().getArchive(null));%0A    assertThat(ex).hasMessageThat().isEqualTo(%22format is not specified%22);%0A  %7D%0A%0A  @Test%0A  public void zipFormatIsDisabled() throws Exception %7B
 %0A   

Test request without specifying a format