def test_context_aware_object_factories(self):
    contents = dedent('\n                 create_java_libraries(base_name="create-java-libraries",\n                                       provides_java_name="test-java",\n                                       provides_scala_name="test-scala")\n                 make_lib("com.foo.test", "does_not_exists", "1.0")\n                 path_util("baz")\n               ')
    self.create_file('3rdparty/BUILD', contents)
    build_file = BuildFile(FileSystemProjectTree(self.build_root), '3rdparty/BUILD')
    address_map = self.build_file_parser.parse_build_file(build_file)
    registered_proxies = set(address_map.values())
    self.assertEqual(len(registered_proxies), 3)
    targets_created = {}
    for target_proxy in registered_proxies:
        targets_created[target_proxy.addressed_name] = target_proxy.addressed_type
    self.assertEqual({'does_not_exists', 'create-java-libraries-scala', 'create-java-libraries-java'}, set(targets_created.keys()))
    self.assertEqual(targets_created['does_not_exists'], self.JarLibrary)
    self.assertEqual(targets_created['create-java-libraries-java'], self.JavaLibrary)
    self.assertEqual(targets_created['create-java-libraries-scala'], self.ScalaLibrary)
    self.assertEqual({'3rdparty/baz'}, self._paths)
def test_context_aware_object_factories(self):
    contents = dedent('\n                 create_java_libraries(base_name="create-java-libraries",\n                                       provides_java_name="test-java",\n                                       provides_scala_name="test-scala")\n                 make_lib("com.foo.test", "does_not_exists", "1.0")\n                 path_util("baz")\n               ')
    self.create_file('3rdparty/BUILD', contents)
    build_file = BuildFile(FileSystemProjectTree(self.build_root), '3rdparty/BUILD')
    address_map = self.build_file_parser.parse_build_file(build_file)
    registered_proxies = set(address_map.values())
    self.assertEqual(len(registered_proxies), 3)
    targets_created = {}
    for target_proxy in registered_proxies:
        targets_created[target_proxy.addressed_name] = target_proxy.addressed_type
    self.assertEqual({'does_not_exists', 'create-java-libraries-scala', 'create-java-libraries-java'}, set(targets_created.keys()))
    self.assertEqual(targets_created['does_not_exists'], self.JarLibrary)
    self.assertEqual(targets_created['create-java-libraries-java'], self.JavaLibrary)
    self.assertEqual(targets_created['create-java-libraries-scala'], self.ScalaLibrary)
    self.assertEqual({'3rdparty/baz'}, self._paths)