Search in sources :

Example 1 with TSClassType

use of io.crnk.gen.typescript.model.TSClassType in project crnk-framework by crnk-project.

the class TypescriptUtilsTest method getNestedInterfacesThrowsExceptionOnCreateIfNoParent.

@Test(expected = IllegalStateException.class)
public void getNestedInterfacesThrowsExceptionOnCreateIfNoParent() {
    TSClassType classType = new TSClassType();
    classType.setName("TestClass");
    TypescriptUtils.getNestedInterface(classType, "TestInterface", true);
}
Also used : TSClassType(io.crnk.gen.typescript.model.TSClassType) Test(org.junit.Test)

Example 2 with TSClassType

use of io.crnk.gen.typescript.model.TSClassType in project crnk-framework by crnk-project.

the class TypescriptUtilsTest method getNestedInterfaesCreatesNewInterface.

@Test
public void getNestedInterfaesCreatesNewInterface() {
    TSModule module = new TSModule();
    module.setName("TestModule");
    TSClassType classType = new TSClassType();
    classType.setParent(module);
    classType.setName("TestClass");
    module.getElements().add(classType);
    TSInterfaceType testInterface = TypescriptUtils.getNestedInterface(classType, "TestInterface", true);
    Assert.assertEquals("TestInterface", testInterface.getName());
    Assert.assertTrue(testInterface.getParent() instanceof TSModule);
    Assert.assertEquals(module, testInterface.getParent().getParent());
    Assert.assertEquals("TestClass", ((TSModule) testInterface.getParent()).getName());
    Assert.assertEquals(2, module.getElements().size());
}
Also used : TSModule(io.crnk.gen.typescript.model.TSModule) TSClassType(io.crnk.gen.typescript.model.TSClassType) TSInterfaceType(io.crnk.gen.typescript.model.TSInterfaceType) Test(org.junit.Test)

Example 3 with TSClassType

use of io.crnk.gen.typescript.model.TSClassType in project crnk-framework by crnk-project.

the class TypescriptUtilsTest method getNestedInterfacesReturnsNullIfDoesNotExistsAndNonCreateRequested.

@Test
public void getNestedInterfacesReturnsNullIfDoesNotExistsAndNonCreateRequested() {
    TSModule module = new TSModule();
    module.setName("TestModule");
    TSClassType classType = new TSClassType();
    classType.setParent(module);
    classType.setName("TestClass");
    module.getElements().add(classType);
    TSInterfaceType testInterface = TypescriptUtils.getNestedInterface(classType, "TestInterface", false);
    Assert.assertNull(testInterface);
}
Also used : TSModule(io.crnk.gen.typescript.model.TSModule) TSClassType(io.crnk.gen.typescript.model.TSClassType) TSInterfaceType(io.crnk.gen.typescript.model.TSInterfaceType) Test(org.junit.Test)

Example 4 with TSClassType

use of io.crnk.gen.typescript.model.TSClassType in project crnk-framework by crnk-project.

the class TypescriptUtilsTest method getNestedInterfacesReturnsNullIfNoParent.

@Test
public void getNestedInterfacesReturnsNullIfNoParent() {
    TSClassType classType = new TSClassType();
    classType.setName("TestClass");
    TSInterfaceType testInterface = TypescriptUtils.getNestedInterface(classType, "TestInterface", false);
    Assert.assertNull(testInterface);
}
Also used : TSClassType(io.crnk.gen.typescript.model.TSClassType) TSInterfaceType(io.crnk.gen.typescript.model.TSInterfaceType) Test(org.junit.Test)

Aggregations

TSClassType (io.crnk.gen.typescript.model.TSClassType)4 Test (org.junit.Test)4 TSInterfaceType (io.crnk.gen.typescript.model.TSInterfaceType)3 TSModule (io.crnk.gen.typescript.model.TSModule)2