package com.atlassian.bitbucket.test.rest.mirror;

import com.atlassian.bitbucket.test.rest.server.stub.mirror.StubMirror;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import static com.atlassian.bitbucket.test.DefaultFuncTestData.getAdminPassword;
import static com.atlassian.bitbucket.test.DefaultFuncTestData.getAdminUser;
import static com.atlassian.bitbucket.test.StatusCodesTestHelper.matching;
import static com.jayway.restassured.RestAssured.given;

public class MirroringInstallationHelper {

    public static com.jayway.restassured.response.Response uninstall(StubMirror mirror, Response.Status... statuses) {
        return given()
                .auth().preemptive().basic(getAdminUser(), getAdminPassword())
                .contentType(MediaType.APPLICATION_JSON)
                .log().ifValidationFails()
                .expect()
                .statusCode(matching(statuses))
                .log().ifValidationFails()
                .when().delete(MirroringRequestHelper.getAddOnUrl(mirror));
    }
}
