Skip to content

Commit

Permalink
Fomatting code, and adding a javaToDot test
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianKarl-zz committed Oct 27, 2015
1 parent 75e275c commit 88f2ea5
Showing 1 changed file with 21 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,6 @@
* THE SOFTWARE.
* #L%
*/
// This file is part of the GraphWalker java package
// The MIT License
//
// Copyright (c) 2010 graphwalker.org
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package org.graphwalker.cli;

Expand Down Expand Up @@ -79,7 +57,7 @@ public void convertJsonToGraphml() throws IOException {
String args[] = {"convert", "--input", "json/example.json", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -88,7 +66,7 @@ public void convertJsonToJava() throws IOException {
String args[] = {"convert", "--input", "json/example.json", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -97,7 +75,7 @@ public void convertJsonToDot() throws IOException {
String args[] = {"convert", "--input", "json/example.json", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -106,14 +84,15 @@ public void convertGraphmlToGraphml() throws IOException {
String args[] = {"convert", "--input", "graphml/UC01_GW2.graphml", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

/**
* The java file generated, can be compiled with the cli jar, like:
* java -jar graphwalker-cli.jar convert -i UC01.graphml UC01.java
* javac -cp graphwalker-cli.jar UC01.java
* java -cp .:graphwalker-cli.jar UC01
*
* @throws IOException
*/
@Test
Expand All @@ -122,7 +101,7 @@ public void convertGraphmlToJava() throws IOException {
String args[] = {"convert", "--input", "graphml/UC01_GW2.graphml", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -131,7 +110,7 @@ public void convertGraphmlToDot() throws IOException {
String args[] = {"convert", "--input", "graphml/UC01_GW2.graphml", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -140,7 +119,7 @@ public void convertGraphmlToJson() throws IOException {
String args[] = {"convert", "--input", "graphml/UC01_GW2.graphml", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -149,7 +128,7 @@ public void convertDotToDot() throws IOException {
String args[] = {"convert", "--input", "dot/SimpleGW.dot", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -158,7 +137,7 @@ public void convertDotToJava() throws IOException {
String args[] = {"convert", "--input", "dot/SimpleGW.dot", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -167,7 +146,7 @@ public void convertDotToGraphml() throws IOException {
String args[] = {"convert", "--input", "dot/SimpleGW.dot", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
Expand All @@ -176,6 +155,15 @@ public void convertDotToJson() throws IOException {
String args[] = {"convert", "--input", "dot/SimpleGW.dot", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertThat(result.getError(), is(""));
Assert.assertTrue(tempFile.length()>0);
Assert.assertTrue(tempFile.length() > 0);
}

@Test
public void convertJavaToDot() throws IOException {
File tempFile = testFolder.newFile("SimpleGW.dot");
String args[] = {"convert", "--input", "dot/SimpleGW.java", tempFile.getPath()};
Result result = runCommand(args);
Assert.assertTrue(result.getError().contains("Creating a model from Java is not supported"));
Assert.assertTrue(tempFile.length() == 0);
}
}

0 comments on commit 88f2ea5

Please sign in to comment.