view src/test/java/de/intevation/lada/test/land/ProbeTest.java @ 832:59c51da59b30

Refactored test environment. Land tests are using arquillian persistence extension (built on DBUnit).
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 18 Dec 2015 18:01:00 +0100
parents
children cb1cfc8c81ed
line wrap: on
line source
package de.intevation.lada.test.land;

import java.net.URL;
import java.util.Arrays;
import java.util.List;

import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonValue;

import org.junit.Assert;

import de.intevation.lada.Protocol;

public class ProbeTest extends ServiceTest {

    private JsonObject expectedById;
    private JsonObject create;

    /**
     * @return The test protocol
     */
    public List<Protocol> getProtocol() {
        return protocol;
    }

    @Override
    public void init(
        URL baseUrl,
        List<Protocol> protocol
    ) {
        super.init(baseUrl, protocol);
        // Attributes with timestamps
        timestampAttributes = Arrays.asList(new String[]{
            "letzteAenderung",
            "probeentnahmeBeginn",
            "solldatumBeginn",
            "solldatumEnde",
            "treeModified"
        });

        // Prepare expected probe object
        JsonObject content = readJsonResource("/datasets/dbUnit_probe.json");
        JsonObject probe = content.getJsonArray("land.probe").getJsonObject(0);
        JsonObjectBuilder builder = convertObject(probe);
        JsonObject trans =
            content.getJsonArray("land.probe_translation").getJsonObject(0);
        builder.add("probeIdAlt", trans.get("probe_id_alt"));
        builder.add("mittelungsdauer", JsonValue.NULL);
        builder.add("probeentnahmeEnde", JsonValue.NULL);
        builder.add("erzeugerId", JsonValue.NULL);
        builder.add("mplId", JsonValue.NULL);
        builder.add("readonly", JsonValue.FALSE);
        builder.add("owner", JsonValue.TRUE);
        expectedById = builder.build();
        Assert.assertNotNull(expectedById);

        // Load probe object to test POST request
        create = readJsonResource("/datasets/probe.json");
        Assert.assertNotNull(create);
    }

    public final void execute() {
        getAll("probe", "rest/probe");
        getById("probe", "rest/probe/1000", expectedById);
        filter("probe", "rest/probe?qid=2&mst_id=11010&umw_id=N24");
        JsonObject created = create("probe", "rest/probe", create);
        update("probe", "rest/probe/1000", "hauptprobenNr", "120510002", "130510002");
        delete("probe", "rest/probe/" + created.getJsonObject("data").get("id"));
    }
}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)