package manage.control;

import com.github.tomakehurst.wiremock.junit.WireMockRule;
import io.restassured.specification.RequestSpecification;
import manage.AbstractIntegrationTest;
import manage.model.OrphanMetaData;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_OK;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;

@SuppressWarnings("unchecked")
public class SystemControllerTest extends AbstractIntegrationTest {

    @Value("${push.user}")
    private String pushUser;

    @Value("${push.password}")
    private String pushPassword;

    @Test
    public void pushPreview() throws Exception {
        Map connections = given()
            .when()
            .get("manage/api/client/playground/pushPreview")
            .then()
            .statusCode(SC_OK)
            .extract().as(Map.class);
        Map expected = objectMapper.readValue(readFile("push/push.expected.json"), Map.class);
        assertEquals(expected, connections);
    }

    @Test
    public void validate() throws Exception {
        String body = given()
            .when()
            .get("manage/api/client/playground/validate")
            .then()
            .statusCode(SC_OK)
            .extract().asString();
        assertEquals("{}", body);
    }

    @Test
    public void orphans() throws Exception {
        List orphans = given()
            .when()
            .get("manage/api/client/playground/orphans")
            .then()
            .statusCode(SC_OK)
            .extract().as(List.class);
        List expected = objectMapper.readValue(readFile("json/expected_orphans.json"), List.class);

        assertEquals(expected, orphans);

        given()
            .when()
            .delete("manage/api/client/playground/deleteOrphans")
            .then()
            .statusCode(SC_OK);

        given()
            .when()
            .get("manage/api/client/playground/orphans")
            .then()
            .statusCode(SC_OK)
            .body("size()", is(0));
    }
}
@@ -29,214 +29,38 @@
 ort 
-com.github.tomakehurst.wiremock.junit.WireMockRule;%0Aimport io.restassured.specification.RequestSpecification;%0Aimport manage.AbstractIntegrationTest;%0Aimport manage.model.OrphanMetaData;%0Aimport org.junit.Rule
+manage.AbstractIntegrationTest
 ;%0Aim
@@ -144,33 +144,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A
 impo
@@ -190,298 +190,8 @@
 p;%0A%0A
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;%0Aimport static com.github.tomakehurst.wiremock.client.WireMock.post;%0Aimport static com.github.tomakehurst.wiremock.client.WireMock.stubFor;%0Aimport static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;%0A
 impo
@@ -286,53 +286,8 @@
 OK;%0A
-import static org.hamcrest.Matchers.equalTo;%0A
 impo

Reformat imports