Search in sources :

Example 16 with Survey

use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.

the class ConnectedSurveysTest method testSecondaryConnectedSurveyGetsTranslatedCorrectly.

@Test
public void testSecondaryConnectedSurveyGetsTranslatedCorrectly() throws Exception {
    Survey currentSurvey = getBasicSurvey("current");
    Survey joinedSurvey0 = getBasicSurvey("joined-0");
    Survey joinedSurvey1 = getBasicSurvey("joined-1");
    connectTwoSurveys(currentSurvey, currentSurvey.getActiveStation(), joinedSurvey0, joinedSurvey0.getOrigin());
    connectTwoSurveys(joinedSurvey0, joinedSurvey0.getActiveStation(), joinedSurvey1, joinedSurvey1.getOrigin());
    GraphActivity activity = new PlanActivity();
    Space<Coord2D> planProjection = Projection2D.PLAN.project(currentSurvey);
    Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(activity, currentSurvey, planProjection);
    Assert.assertEquals(translated.size(), 2);
    Survey translatedSurvey = getNamedSurvey(translated, "joined-1");
    Space<Coord2D> projection = translated.get(translatedSurvey);
    assert projection != null;
    Coord2D newStationPoint = getStationPosition(projection, "2");
    Assert.assertEquals(-3.0, newStationPoint.y, SexyTopo.ALLOWED_DOUBLE_DELTA);
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Example 17 with Survey

use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.

the class ConnectedSurveysTest method testNoConnectedSurveysReturnNoUpdatedSurveys.

@Test
public void testNoConnectedSurveysReturnNoUpdatedSurveys() {
    Survey currentSurvey = getBasicSurvey("not-connected");
    // As of v2 of Mockito the following emits an 'UnnecessaryStubbingException'
    // Sketch fakeSketch = new Sketch();
    // when(mockActivity.getSketch(currentSurvey)).thenReturn(fakeSketch);
    Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(mockActivity, currentSurvey, new Space<>());
    Assert.assertEquals(translated.size(), 0);
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) Test(org.junit.Test)

Example 18 with Survey

use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.

the class ConnectedSurveysTest method testConnectedSurveyGetsTranslatedCorrectly.

@Test
public void testConnectedSurveyGetsTranslatedCorrectly() throws Exception {
    Survey currentSurvey = getBasicSurvey("current");
    Survey joinedSurvey = getBasicSurvey("joined");
    connectTwoSurveys(currentSurvey, currentSurvey.getActiveStation(), joinedSurvey, joinedSurvey.getOrigin());
    GraphActivity activity = new PlanActivity();
    Space<Coord2D> planProjection = Projection2D.PLAN.project(currentSurvey);
    Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(activity, currentSurvey, planProjection);
    Assert.assertEquals(translated.size(), 1);
    Survey translatedSurvey = getNamedSurvey(translated, "joined");
    Space<Coord2D> projection = translated.get(translatedSurvey);
    assert projection != null;
    Coord2D newStationPoint = getStationPosition(projection, "2");
    Assert.assertEquals(-2.0, newStationPoint.y, SexyTopo.ALLOWED_DOUBLE_DELTA);
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Example 19 with Survey

use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.

the class ConnectedSurveysTest method getBasicSurvey.

private static Survey getBasicSurvey(String name) {
    Survey basicSurvey = new Survey(name);
    Leg l0 = new Leg(1.0f, 0.0f, 0.0f);
    SurveyUpdater.update(basicSurvey, l0);
    SurveyUpdater.upgradeSplayToConnectedLeg(basicSurvey, l0, InputMode.FORWARD);
    return basicSurvey;
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 20 with Survey

use of org.hwyl.sexytopo.model.survey.Survey in project sexytopo by richsmith.

the class MetadataTranslaterTest method testActiveStationIsTParsed.

@Test
public void testActiveStationIsTParsed() throws Exception {
    Survey survey = new Survey("test");
    String text = "{\"active-station\":\"1\",\"connections\":{}}";
    MetadataTranslater.translateAndUpdate(null, survey, text);
    Assert.assertEquals(survey.getActiveStation().getName(), "1");
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Survey (org.hwyl.sexytopo.model.survey.Survey)101 Test (org.junit.Test)56 Station (org.hwyl.sexytopo.model.survey.Station)31 Leg (org.hwyl.sexytopo.model.survey.Leg)24 AlertDialog (android.app.AlertDialog)10 SuppressLint (android.annotation.SuppressLint)9 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)9 ArrayAdapter (android.widget.ArrayAdapter)8 File (java.io.File)6 HashMap (java.util.HashMap)6 View (android.view.View)5 EditText (android.widget.EditText)5 ArrayList (java.util.ArrayList)5 Set (java.util.Set)5 Context (android.content.Context)4 SharedPreferences (android.content.SharedPreferences)4 Editable (android.text.Editable)4 List (java.util.List)4 Map (java.util.Map)4 R (org.hwyl.sexytopo.R)4