1+ /*
2+ * Copyright © 2015 Stefan Niederhauser ([email protected] ) 3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
116package guru .nidi .graphviz .engine ;
217
318import org .junit .jupiter .api .Test ;
@@ -15,22 +30,32 @@ void fromJsonMinimal() {
1530 }
1631
1732 @ Test
18- void fromJsonEmptyImages () {
33+ void fromJsonNoImage () {
1934 final Options options = Options .fromJson ("{engine:'DOT',format:'PNG',totalMemory:'42',yInvert:true,basedir:'hula'}" );
2035 final Options expected = Options .create ().engine (Engine .DOT ).format (Format .PNG ).totalMemory (42 ).yInvert (true ).basedir (new File ("hula" ));
2136 assertEquals (expected , options );
2237 }
2338
39+ @ Test
40+ void fromJsonEmptyImages () {
41+ final Options options = Options .fromJson ("{engine:'DOT',format:'PNG',totalMemory:'42',yInvert:true,basedir:'hula',images:[]}" );
42+ final Options expected = Options .create ().engine (Engine .DOT ).format (Format .PNG ).totalMemory (42 ).yInvert (true ).basedir (new File ("hula" ));
43+ assertEquals (expected , options );
44+ }
45+
2446 @ Test
2547 void fromJsonOneImage () throws IOException {
26- final Options options = Options .fromJson ("{engine:'DOT',format:'PNG',images:[{path:'example/ex1.png',width:'550px',height:'100px'}]}" );
48+ final Options options = Options .fromJson ("{engine:'DOT',format:'PNG',images:["
49+ + "{path:'" + new File ("." ).getAbsolutePath () + "/example/ex1.png',width:'550px',height:'100px'}]}" );
2750 final Options expected = Options .create ().engine (Engine .DOT ).format (Format .PNG ).image ("example/ex1.png" );
2851 assertEquals (expected , options );
2952 }
3053
3154 @ Test
3255 void fromJsonTwoImages () throws IOException {
33- final Options options = Options .fromJson ("{engine:'DOT',format:'PNG',images:[{path:'example/ex1.png',width:'550px',height:'100px'},{path:'example/ex2.png',width:'900px',height:'964px']}" );
56+ final Options options = Options .fromJson ("{engine:'DOT',format:'PNG',images:["
57+ + "{path:'" + new File ("." ).getAbsolutePath () + "/example/ex1.png',width:'550px',height:'100px'},"
58+ + "{path:'" + new File ("." ).getAbsolutePath () + "/example/ex2.png',width:'900px',height:'964px']}" );
3459 final Options expected = Options .create ().engine (Engine .DOT ).format (Format .PNG ).image ("example/ex1.png" ).image ("example/ex2.png" );
3560 assertEquals (expected , options );
3661 }
@@ -50,7 +75,8 @@ void toJsonEmptyImages() {
5075 @ Test
5176 void toJsonOneImage () {
5277 final String s = Options .create ().engine (Engine .DOT ).format (Format .PNG ).basedir (new File ("example" )).image ("ex1.png" ).toJson (false );
53- assertEquals ("{format:'svg',engine:'dot',basedir:'" + new File ("example" ).getAbsolutePath () + "',images:[{path:'" + new File ("example/ex1.png" ).getAbsolutePath () + "',width:'550px',height:'100px'}]}" , s );
78+ assertEquals ("{format:'svg',engine:'dot',basedir:'" + new File ("example" ).getAbsolutePath () + "',images:[" +
79+ "{path:'" + new File ("example/ex1.png" ).getAbsolutePath () + "',width:'550px',height:'100px'}]}" , s );
5480 }
5581
5682 @ Test
0 commit comments