1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.rblasch.convert;
17
18 import junit.framework.TestCase;
19 import org.rblasch.convert.graph.Graph;
20 import org.rblasch.convert.graph.SparseWeightedDirectedGraph;
21 import org.rblasch.convert.type.Type;
22 import org.rblasch.convert.type.Types;
23
24 /***
25 * Created by IntelliJ IDEA.
26 * User: rb
27 * Date: Oct 27, 2004
28 * Time: 11:39:31 PM
29 * To change this template use File | Settings | File Templates.
30 */
31 public class GraphTest extends TestCase {
32 public void testSimple() {
33 final Graph g = new SparseWeightedDirectedGraph();
34 g.addConnection(
35 new TypeVertex(Types.findTypeByClass(Object.class)),
36 new ConverterEdge(new MetaConverter() {
37 public Type getSourceType() {
38 return Types.findTypeByClass(Object.class);
39 }
40
41 public Type getDestinationType() {
42 return Types.findTypeByClass(String.class);
43 }
44
45 public int getWeight() {
46 return 10;
47 }
48
49 public Converter getConverter() {
50 return new Converter() {
51 public Object convert(Object obj) throws Exception {
52 return obj.toString();
53 }
54 };
55 }
56 }, 1),
57 new TypeVertex(Types.findTypeByClass(String.class)));
58 }
59 }