def testToClassName(self):
        """Test creating safe class names from object names."""
        # 'parameters': {}
        api = java_generator.JavaApi({
            'name': 'dummy',
            'version': 'v1',
            'resources': {
                'foo': {
                    'methods': {
                        'bar': {
                            'id': 'bar',
                        }
                    }
                }
            }
        })
        self.assertEquals('Foo', api.ToClassName('foo', api))
        self.assertEquals('DummyClass', api.ToClassName('class', None))
        self.assertEquals('DummyDefault', api.ToClassName('default', None))
        self.assertEquals('DummyImport', api.ToClassName('import', None))
        self.assertEquals('DummyObject', api.ToClassName('object', None))
        self.assertEquals('DummyString', api.ToClassName('string', None))
        self.assertEquals('DummyTrue', api.ToClassName('true', None))
        self.assertEquals('dummy', api.values['name'])
        self.assertEquals('Dummy', api._class_name)

        # Test the renaming of the object when it matches the API name.
        self.assertEquals('Dummy', api.ToClassName('dummy', api))
        foo = api._resources[0]
        self.assertEquals(
            'DummyOperations',
            api.ToClassName('dummy', foo, element_type='resource'))
        bar = foo._methods[0]
        self.assertEquals('DummyOperation',
                          api.ToClassName('dummy', bar, element_type='method'))
 def testToClassNameWithCanonical(self):
     api = java_generator.JavaApi({
         'name': 'dummy',
         'canonicalName': 'Dummy Service',
         'version': 'v1',
         'resources': {}
     })
     self.assertEquals('dummy', api.values['name'])
     self.assertEquals('DummyService', api._class_name)
     self.assertEquals('DummyServiceClass', api.ToClassName('class', None))