@Test(expected = SidoClosedItemException.class) public void addType_closed() { SidoContext context = mock(SidoContext.class); DefaultSidoSchema schema = new DefaultSidoSchema(context, UID); schema.close(); schema.addType(mock(SidoType.class)); }
@Test public void getType_not_required() { SidoContext context = mock(SidoContext.class); DefaultSidoSchema schema = new DefaultSidoSchema(context, UID); SidoType type = schema.getType("Person", false); assertNull(type); }
@Test public void addType() { SidoContext context = mock(SidoContext.class); DefaultSidoSchema schema = new DefaultSidoSchema(context, UID); SidoType type = mock(SidoType.class); when(type.getName()).thenReturn("Person"); schema.addType(type); assertSame(type, schema.getType("Person", true)); }
@Test public void constructor() { SidoContext context = mock(SidoContext.class); DefaultSidoSchema schema = new DefaultSidoSchema(context, UID); assertSame(context, schema.getContext()); assertEquals(UID, schema.getUid()); assertEquals(UID, schema.toString()); Collection<SidoType> types = schema.getTypes(); assertNotNull(types); assertTrue(types.isEmpty()); }
@Test(expected = SidoTypeNotFoundInSchemaException.class) public void getType_required() { SidoContext context = mock(SidoContext.class); DefaultSidoSchema schema = new DefaultSidoSchema(context, UID); schema.getType("Person", true); }