def test_class_serialization(self):
        """Tests JSON serialization of a class dependency graph."""
        test_graph = class_dependency.JavaClassDependencyGraph()
        test_graph.add_edge_if_new(self.CLASS_1, self.CLASS_2)
        test_graph.add_edge_if_new(self.CLASS_1, self.CLASS_3)
        test_graph.add_edge_if_new(self.CLASS_2, self.CLASS_3)
        test_graph.add_nested_class_to_key(self.CLASS_1, self.CLASS_1_NESTED_1)
        test_graph.add_nested_class_to_key(self.CLASS_1, self.CLASS_1_NESTED_2)
        test_graph.add_nested_class_to_key(self.CLASS_2, self.CLASS_2_NESTED_1)

        test_json_obj = serialization.create_json_obj_from_graph(test_graph)

        self.assertEqual(test_json_obj, self.JSON_CLASS_GRAPH)
Beispiel #2
0
    def test_package_serialization(self):
        """Tests JSON serialization of a package dependency graph."""
        class_graph = class_dependency.JavaClassDependencyGraph()
        class_graph.add_edge_if_new(self.CLASS_1, self.CLASS_2)
        class_graph.add_edge_if_new(self.CLASS_1, self.CLASS_3)
        class_graph.add_edge_if_new(self.CLASS_2, self.CLASS_3)
        class_graph.get_node_by_key(self.CLASS_1).add_nested_class(
            self.CLASS_1_NESTED_1)
        class_graph.get_node_by_key(self.CLASS_1).add_nested_class(
            self.CLASS_1_NESTED_2)
        class_graph.get_node_by_key(self.CLASS_2).add_nested_class(
            self.CLASS_2_NESTED_1)

        package_graph = package_dependency.JavaPackageDependencyGraph(
            class_graph)
        test_json_obj = serialization.create_json_obj_from_graph(package_graph)

        self.assertEqual(test_json_obj, self.JSON_PACKAGE_GRAPH)