Search in sources :

Example 71 with Survey

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

the class ConnectedSurveysTest method testConnectedSurveySketchGetsTranslatedCorrectly.

@Test
public void testConnectedSurveySketchGetsTranslatedCorrectly() {
    Survey currentSurvey = getBasicSurvey("current");
    Survey joinedSurvey = getBasicSurvey("joined");
    Sketch sketch = joinedSurvey.getPlanSketch();
    PathDetail pathDetail = sketch.startNewPath(new Coord2D(0, 0));
    pathDetail.lineTo(new Coord2D(0, 1));
    sketch.finishPath();
    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);
    Sketch translatedSketch = translated.keySet().iterator().next().getPlanSketch();
    PathDetail translatedPathDetail = translatedSketch.getPathDetails().toArray(new PathDetail[] {})[0];
    List<Coord2D> coords = translatedPathDetail.getPath();
    Assert.assertEquals(new Coord2D(0, -1), coords.get(0));
    Assert.assertEquals(new Coord2D(0, 0), coords.get(1));
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Example 72 with Survey

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

the class MetadataTranslaterTest method testJsonIsTranslatedToSurveyWithActiveStation.

@Test
public void testJsonIsTranslatedToSurveyWithActiveStation() throws Exception {
    String json = "{\"active-station\":\"1\",\"connections\":{}}";
    Survey testSurvey = BasicTestSurveyCreator.createStraightNorth();
    testSurvey.setActiveStation(testSurvey.getStationByName("2"));
    MetadataTranslater.translateAndUpdate(null, testSurvey, json);
    Assert.assertEquals("1", testSurvey.getActiveStation().getName());
    Assert.assertEquals(0, testSurvey.getConnectedSurveys().size());
}
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)

Example 73 with Survey

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

the class MetadataTranslaterTest method testConnectedSurveyIsTranslatedToJson.

@Test
public void testConnectedSurveyIsTranslatedToJson() throws Exception {
    Survey survey = new Survey("first");
    Survey connectedSurvey = new Survey("connected");
    connectTwoSurveys(survey, survey.getOrigin(), connectedSurvey, connectedSurvey.getOrigin());
    String translated = MetadataTranslater.translate(survey);
    Assert.assertEquals("{\"active-station\":\"1\",\"connections\":{\"1\":[[\"connected\",\"1\"]]}}", translated.replaceAll("\\s", ""));
}
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)

Example 74 with Survey

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

the class MetadataTranslaterTest method testConnectedSurveyJsonIsTranslatedToConnectedSurvey.

@Test
public void testConnectedSurveyJsonIsTranslatedToConnectedSurvey() throws Exception {
    String json = "{\"active-station\":\"1\",\"connections\":{\"1\":[[\"connected\",\"1\"]]}}";
    Survey survey = new Survey("test");
    Survey connected = new Survey("connected");
    PowerMockito.mockStatic(Loader.class);
    Mockito.when(Loader.loadSurvey((Context) any(), anyString(), anySet(), anyBoolean())).thenReturn(connected);
    MetadataTranslater.translateAndUpdate(null, survey, json);
    Assert.assertEquals(1, survey.getConnectedSurveys().size());
}
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)

Example 75 with Survey

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

the class SurvexImporterTest method testBasicImportHandlesComments.

@Test
public void testBasicImportHandlesComments() throws Exception {
    final String testContent = "1\t2\t5.0\t0.0\t0.0\t; {from: 5.0 0.0 0.0, 5.0 0.0 0.0, 5.0 0.0 0.0} testComment";
    Survey survey = new Survey("Test");
    SurvexImporter.parse(testContent, survey);
    Station created = survey.getStationByName("2");
    Assert.assertEquals(created.getComment(), "testComment");
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Survey(org.hwyl.sexytopo.model.survey.Survey) Test(org.junit.Test)

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