1   /*
2    * Copyright 2004 Ronald Blaschke.
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   */
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  }