package it.com.atlassian.stash;

import com.atlassian.bitbucket.test.BaseRetryingFuncTest;
import com.atlassian.bitbucket.test.DefaultFuncTestData;
import com.atlassian.bitbucket.test.runners.FuncTestSplitterRunner;
import com.jayway.restassured.RestAssured;
import org.junit.runner.RunWith;

import static javax.ws.rs.core.Response.Status.NOT_FOUND;
import static javax.ws.rs.core.Response.Status.NO_CONTENT;

@RunWith(FuncTestSplitterRunner.class)
public abstract class BaseRestTest extends BaseRetryingFuncTest {

    protected void assert404(String resourceUrl) {
        RestAssured
                .given()
                .auth().preemptive().basic(DefaultFuncTestData.getAdminUser(), DefaultFuncTestData.getAdminPassword())
                .expect()
                .statusCode(NOT_FOUND.getStatusCode())
                .when().get(resourceUrl);
    }

    protected void delete(String resourceUrl) {
        RestAssured
                .given()
                .auth().preemptive().basic(DefaultFuncTestData.getAdminUser(), DefaultFuncTestData.getAdminPassword())
                .expect()
                .statusCode(NO_CONTENT.getStatusCode())
                .when().delete(resourceUrl);
    }
}
