Search in sources :

Example 21 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class OSMMapTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    File workingDirectory = tempFolder.getRoot();
    TestPlatform platform = new TestPlatform(workingDirectory);
    GlobalContextBuilder.builder = new CLITestContextBuilder(platform);
    cli.setPlatform(platform);
    cli.execute("init");
    cli.execute("config", "user.name", "Gabriel Roldan");
    cli.execute("config", "user.email", "groldan@boundlessgeo.com");
    assertTrue(new File(workingDirectory, ".geogig").exists());
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) TestPlatform(org.locationtech.geogig.api.TestPlatform) File(java.io.File) CLITestContextBuilder(org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder) Before(org.junit.Before)

Example 22 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class OSMUnmapTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    File workingDirectory = tempFolder.getRoot();
    TestPlatform platform = new TestPlatform(workingDirectory);
    GlobalContextBuilder.builder = new CLITestContextBuilder(platform);
    cli.setPlatform(platform);
    cli.execute("init");
    cli.execute("config", "user.name", "Gabriel Roldan");
    cli.execute("config", "user.email", "groldan@boundlessgeo.com");
    assertTrue(new File(workingDirectory, ".geogig").exists());
    // import with mapping
    String filename = OSMImportOp.class.getResource("nodes.xml").getFile();
    File file = new File(filename);
    String mappingFilename = OSMMap.class.getResource("nodes_mapping_with_aliases.json").getFile();
    File mappingFile = new File(mappingFilename);
    cli.execute("osm", "import", file.getAbsolutePath(), "--mapping", mappingFile.getAbsolutePath());
    GeoGIG geogig = cli.newGeoGIG();
    Optional<RevFeature> revFeature = geogig.command(RevObjectParse.class).setRefSpec("WORK_HEAD:busstops/507464799").call(RevFeature.class);
    assertTrue(revFeature.isPresent());
    geogig.getRepository().workingTree().delete("node");
    Optional<RevTree> tree = geogig.command(RevObjectParse.class).setRefSpec("WORK_HEAD:node").call(RevTree.class);
    assertFalse(tree.isPresent());
    geogig.close();
}
Also used : ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) OSMImportOp(org.locationtech.geogig.osm.internal.OSMImportOp) GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) RevFeature(org.locationtech.geogig.api.RevFeature) TestPlatform(org.locationtech.geogig.api.TestPlatform) File(java.io.File) CLITestContextBuilder(org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder) GeoGIG(org.locationtech.geogig.api.GeoGIG) RevTree(org.locationtech.geogig.api.RevTree) Before(org.junit.Before)

Example 23 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class OracleDescribeTest method testFlushException.

@Test
public void testFlushException() throws Exception {
    ConsoleReader consoleReader = spy(new ConsoleReader(System.in, System.out, new UnsupportedTerminal()));
    GeogigCLI testCli = new GeogigCLI(consoleReader);
    setUpGeogig(testCli);
    doThrow(new IOException("Exception")).when(consoleReader).flush();
    OracleDescribe describeCommand = new OracleDescribe();
    describeCommand.table = "table1";
    describeCommand.dataStoreFactory = TestHelper.createTestFactory();
    exception.expect(Exception.class);
    describeCommand.run(testCli);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) IOException(java.io.IOException) Test(org.junit.Test)

Example 24 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class OracleDescribeTest method setUp.

@Before
public void setUp() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    cli = new GeogigCLI(consoleReader);
    setUpGeogig(cli);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) Before(org.junit.Before)

Example 25 with ConsoleReader

use of jline.console.ConsoleReader in project GeoGig by boundlessgeo.

the class OracleListTest method testListException.

@Test
public void testListException() throws Exception {
    ConsoleReader consoleReader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
    GeogigCLI mockCli = spy(new GeogigCLI(consoleReader));
    setUpGeogig(mockCli);
    when(mockCli.getConsole()).thenThrow(new MockitoException("Exception"));
    OracleList listCommand = new OracleList();
    listCommand.dataStoreFactory = TestHelper.createTestFactory();
    exception.expect(MockitoException.class);
    listCommand.run(mockCli);
}
Also used : GeogigCLI(org.locationtech.geogig.cli.GeogigCLI) ConsoleReader(jline.console.ConsoleReader) UnsupportedTerminal(jline.UnsupportedTerminal) MockitoException(org.mockito.exceptions.base.MockitoException) Test(org.junit.Test)

Aggregations

ConsoleReader (jline.console.ConsoleReader)95 UnsupportedTerminal (jline.UnsupportedTerminal)44 GeogigCLI (org.locationtech.geogig.cli.GeogigCLI)42 GeoGIG (org.locationtech.geogig.api.GeoGIG)22 Before (org.junit.Before)19 IOException (java.io.IOException)17 Test (org.junit.Test)17 File (java.io.File)12 MockitoException (org.mockito.exceptions.base.MockitoException)12 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)11 ObjectId (org.locationtech.geogig.api.ObjectId)9 TestPlatform (org.locationtech.geogig.api.TestPlatform)8 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)8 Ref (org.locationtech.geogig.api.Ref)7 CLITestContextBuilder (org.locationtech.geogig.cli.test.functional.general.CLITestContextBuilder)7 Ansi (org.fusesource.jansi.Ansi)6 NodeRef (org.locationtech.geogig.api.NodeRef)6 RevCommit (org.locationtech.geogig.api.RevCommit)6 FileInputStream (java.io.FileInputStream)4 RevObject (org.locationtech.geogig.api.RevObject)4