package au.gov.amsa.detection;

import java.util.Date;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import au.gov.amsa.detection.model.Context;
import au.gov.amsa.detection.model.Craft;
import au.gov.amsa.detection.model.CraftType;
import au.gov.amsa.detection.model.DetectionRule;
import au.gov.amsa.detection.model.SimpleRegion;
import xuml.tools.model.compiler.runtime.SignalProcessorListenerUtilLogging;
import xuml.tools.util.database.DerbyUtil;

public class AppTest {

    @BeforeClass
    public static void setup() {
        DerbyUtil.disableDerbyLog();
        Context.setEntityActorListenerFactory(id -> new SignalProcessorListenerUtilLogging());
        App.startup();
    }

    @Test
    public void testApp() {

        SimpleRegion region = Context.create(SimpleRegion.class,
                SimpleRegion.Events.Create.builder().name("EEZ")
                        .description("Australian Exclusive Economic Zone")
                        .zippedShapefileBytes(new byte[] { 1, 2, 3 }).build());
        Context.create(DetectionRule.class,
                DetectionRule.Events.Create.builder().name("Name")
                        .description(
                                "detect entry into Australian EEZ and send information to vessels")
                .startTime(new Date(0)).endTime(new Date(Long.MAX_VALUE))
                .regionID(region.getRegion_R4().getId()).build());
        CraftType vessel = Context.create(CraftType.class, CraftType.Events.Create.builder()
                .name("Vessel").description("A ship or other floating craft").build());
        Craft craft = Context.create(Craft.class,
                Craft.Events.Create.builder().mmsi(123456789).craftTypeID(vessel.getId())
                        .craftIdentifier("123456789").craftIdentifierType("MMSI").build());
        craft.signal(Craft.Events.Position.builder().altitudeMetres(10.0).latitude(-35.0)
                .longitude(142.0).time(new Date()).build());

    }

    @AfterClass
    public static void shutdown() {
        App.shutdown();
    }

}
@@ -1036,32 +1036,33 @@
  3 %7D).build());%0A
+%0A
         Context.
@@ -1427,32 +1427,33 @@
 Id()).build());%0A
+%0A
         CraftTyp
@@ -1609,32 +1609,33 @@
 aft%22).build());%0A
+%0A
         Craft cr
@@ -1758,16 +1758,16 @@
 etId())%0A
-
         
@@ -1846,24 +1846,25 @@
 ).build());%0A
+%0A
         craf

use bytes