Skip to content

Commit

Permalink
Adapt samm-cli to updated diagram generation
Browse files Browse the repository at this point in the history
  • Loading branch information
atextor committed Aug 4, 2023
1 parent 63cdb32 commit 7825554
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected AspectContext loadModelOrFail( final String modelFileName, final Exter
protected void generateDiagram( final String inputFileName, final AspectModelDiagramGenerator.Format targetFormat, final String outputFileName,
final String languageTag, final ExternalResolverMixin resolverConfig ) throws IOException {
final AspectContext context = loadModelOrFail( inputFileName, resolverConfig );
final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( context.rdfModel() );
final AspectModelDiagramGenerator generator = new AspectModelDiagramGenerator( context );
final Set<AspectModelDiagramGenerator.Format> targetFormats = new HashSet<>();
targetFormats.add( targetFormat );
final Set<Locale> languagesUsedInModel = LanguageCollector.collectUsedLanguages( context.rdfModel().getModel() );
Expand Down
8 changes: 0 additions & 8 deletions tools/samm-cli/src/main/java/org/eclipse/esmf/SammCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

import org.fusesource.jansi.AnsiConsole;

import guru.nidi.graphviz.engine.Graphviz;
import org.eclipse.esmf.aspect.AspectCommand;
import org.eclipse.esmf.substitution.GraalVmJsGraphvizEngine;
import picocli.CommandLine;

@CommandLine.Command( name = SammCli.COMMAND_NAME,
Expand Down Expand Up @@ -88,8 +86,6 @@ int runWithExceptionHandler( final CommandLine.IExecutionExceptionHandler except
public static void main( final String[] argv ) {
NativeImageHelpers.ensureRequiredEnvironment();

setupGraphvizJava();

// The disabling color switch needs to be checked before PicoCLI initialization
boolean disableColor = false;
for ( final String arg : argv ) {
Expand All @@ -110,10 +106,6 @@ public static void main( final String[] argv ) {
System.exit( exitCode );
}

private static void setupGraphvizJava() {
Graphviz.useEngine( new GraalVmJsGraphvizEngine() );
}

protected String format( final String string ) {
return commandLine.getColorScheme().ansi().string( string );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.esmf.AbstractCommand;
import org.eclipse.esmf.LoggingMixin;

import org.eclipse.esmf.aspect.to.AspectToDotCommand;
import org.eclipse.esmf.aspect.to.AspectToHtmlCommand;
import org.eclipse.esmf.aspect.to.AspectToJavaCommand;
import org.eclipse.esmf.aspect.to.AspectToOpenapiCommand;
Expand All @@ -32,7 +31,6 @@
@CommandLine.Command( name = AspectToCommand.COMMAND_NAME, description = "Transforms an Aspect Model into another format",
subcommands = {
CommandLine.HelpCommand.class,
AspectToDotCommand.class,
AspectToHtmlCommand.class,
AspectToJavaCommand.class,
AspectToJsonCommand.class,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
[
{
"name": "guru.nidi.graphviz.attribute.Style",
"allDeclaredFields": true,
"allDeclaredMethods": true
},
{
"name": "guru.nidi.graphviz.attribute.Shape",
"allDeclaredFields": true,
"allDeclaredMethods": true
},
{
"name": "guru.nidi.graphviz.engine.ResultHandler",
"allDeclaredFields": true,
"allDeclaredMethods": true
},
{
"name": "java.awt.Color",
"allDeclaredFields": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
{"pattern":"\\Qrdf/dash.ttl\\E"},
{"pattern":"\\Qrdf/shacl.ttl\\E"},
{"pattern":"\\Qrdf/system-triples.ttl\\E"},
{"pattern":"\\Qrdf/tosh.ttl\\E"},
{"pattern":"\\Qguru/nidi/graphviz/engine/render.js\\E"},
{"pattern":"\\QMETA-INF/resources/webjars/viz.js-graphviz-java/2.1.3/viz.js\\E"},
{"pattern":"\\QMETA-INF/resources/webjars/viz.js-graphviz-java/2.1.3/full.render.js\\E"}
{"pattern":"\\Qrdf/tosh.ttl\\E"}
],
"bundles":[{"name":"org.apache.jena.ext.xerces.impl.xpath.regex.message"}]
}
49 changes: 0 additions & 49 deletions tools/samm-cli/src/test/java/org/eclipse/esmf/SammCliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,55 +254,6 @@ public void testAspectToAasJsonToStdout() {
assertThat( contentType( result.stdoutRaw() ) ).isEqualTo( MediaType.text( "plain" ) );
}

@Test
public void testAspectToDotWithDefaultLanguage() {
final File targetFile = outputFile( "output.dot" );
final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot", "-o",
targetFile.getAbsolutePath() );
assertThat( result.stdout() ).isEmpty();
assertThat( result.stderr() ).isEmpty();
assertThat( targetFile ).exists();
assertThat( targetFile ).content().contains( "digraph AspectModel" );
}

@Test
public void testAspectToDotWithGivenLanguage() {
final File targetFile = outputFile( "output.dot" );
final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot", "-o",
targetFile.getAbsolutePath(), "--language",
"en" );
assertThat( result.stdout() ).isEmpty();
assertThat( result.stderr() ).isEmpty();
assertThat( targetFile ).exists();
assertThat( targetFile ).content().startsWith( "digraph AspectModel" );
}

@Test
public void testAspectToDotWithNonExistentLanguage() {
final File targetFile = outputFile( "output.dot" );
final ExecutionResult result = sammCli.apply( "--disable-color", "aspect", defaultInputFile, "to", "dot", "-o", targetFile.getAbsolutePath(),
"--language", "de" );
assertThat( result.exitStatus() ).isEqualTo( 1 );
assertThat( result.stdout() ).isEmpty();
assertThat( result.stderr() ).contains( "The model does not contain the desired language" );
assertThat( targetFile ).doesNotExist();
}

@Test
public void testAspectToDotToStdout() {
final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot" );
assertThat( result.stdout() ).startsWith( "digraph AspectModel" );
assertThat( result.stderr() ).isEmpty();
}

@Test
public void testAspectToDotWithCustomResolver() {
final ExecutionResult result = sammCli.runAndExpectSuccess( "--disable-color", "aspect", defaultInputFile, "to", "dot", "--custom-resolver",
resolverCommand() );
assertThat( result.stdout() ).startsWith( "digraph AspectModel" );
assertThat( result.stderr() ).isEmpty();
}

@Test
public void testAspectToHtmlWithDefaultLanguageToFile() {
final File targetFile = outputFile( "output.html" );
Expand Down

0 comments on commit 7825554

Please sign in to comment.