Search in sources :

Example 1 with FileContentInput

use of com.google.gerrit.extensions.api.changes.FileContentInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method invalidBase64UploadBinaryInChangeEditOneRequestRest.

@Test
public void invalidBase64UploadBinaryInChangeEditOneRequestRest() throws Exception {
    FileContentInput in = new FileContentInput();
    in.binary_content = CONTENT_BINARY_ENCODED_NEW3;
    adminRestSession.put(urlEditFile(changeId, FILE_NAME), in).assertBadRequest();
}
Also used : FileContentInput(com.google.gerrit.extensions.api.changes.FileContentInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 2 with FileContentInput

use of com.google.gerrit.extensions.api.changes.FileContentInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method createAndUploadBinaryInChangeEditOneRequestRest.

@Test
public void createAndUploadBinaryInChangeEditOneRequestRest() throws Exception {
    FileContentInput in = new FileContentInput();
    in.binary_content = CONTENT_BINARY_ENCODED_NEW;
    adminRestSession.put(urlEditFile(changeId, FILE_NAME), in).assertNoContent();
    ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_BINARY_DECODED_NEW);
    in.binary_content = CONTENT_BINARY_ENCODED_NEW2;
    adminRestSession.put(urlEditFile(changeId, FILE_NAME), in).assertNoContent();
    ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_BINARY_DECODED_NEW2);
}
Also used : FileContentInput(com.google.gerrit.extensions.api.changes.FileContentInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 3 with FileContentInput

use of com.google.gerrit.extensions.api.changes.FileContentInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method createAndChangeEditInOneRequestRest.

@Test
public void createAndChangeEditInOneRequestRest() throws Exception {
    FileContentInput in = new FileContentInput();
    in.content = RawInputUtil.create(CONTENT_NEW);
    adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content).assertNoContent();
    ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW);
    in.content = RawInputUtil.create(CONTENT_NEW2);
    adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content).assertNoContent();
    ensureSameBytes(getFileContentOfEdit(changeId, FILE_NAME), CONTENT_NEW2);
}
Also used : FileContentInput(com.google.gerrit.extensions.api.changes.FileContentInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 4 with FileContentInput

use of com.google.gerrit.extensions.api.changes.FileContentInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method changeEditNoContentProvidedRest.

@Test
public void changeEditNoContentProvidedRest() throws Exception {
    createEmptyEditFor(changeId);
    FileContentInput in = new FileContentInput();
    in.binary_content = null;
    adminRestSession.put(urlEditFile(changeId, FILE_NAME), in).assertBadRequest();
}
Also used : FileContentInput(com.google.gerrit.extensions.api.changes.FileContentInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 5 with FileContentInput

use of com.google.gerrit.extensions.api.changes.FileContentInput in project gerrit by GerritCodeReview.

the class ChangeEditIT method getFileContentRest.

@Test
public void getFileContentRest() throws Exception {
    FileContentInput in = new FileContentInput();
    in.content = RawInputUtil.create(CONTENT_NEW);
    adminRestSession.putRaw(urlEditFile(changeId, FILE_NAME), in.content).assertNoContent();
    gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW2));
    RestResponse r = adminRestSession.getJsonAccept(urlEditFile(changeId, FILE_NAME));
    r.assertOK();
    assertThat(readContentFromJson(r)).isEqualTo(new String(CONTENT_NEW2, UTF_8));
    r = adminRestSession.getJsonAccept(urlEditFile(changeId, FILE_NAME, true));
    r.assertOK();
    assertThat(readContentFromJson(r)).isEqualTo(new String(CONTENT_OLD, UTF_8));
}
Also used : FileContentInput(com.google.gerrit.extensions.api.changes.FileContentInput) RestResponse(com.google.gerrit.acceptance.RestResponse) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)6 FileContentInput (com.google.gerrit.extensions.api.changes.FileContentInput)6 Test (org.junit.Test)6 RestResponse (com.google.gerrit.acceptance.RestResponse)1