DefaultTypeCache implements TypeCache { @Override public boolean has(String typeName) throws AtlasException { return types_.containsKey(typeName); }  @Override boolean has(String typeName); @Override boolean has(TypeCategory typeCategory, String typeName); @Override IDataType get(String typeName); @Override IDataType get(TypeCategory typeCategory, String typeName); @Override Collection<String> getTypeNames(Map<TYPE_FILTER, String> filterMap); @Override Collection<String> getAllTypeNames(); @Override void put(IDataType type); @Override void putAll(Collection<IDataType> types); @Override void remove(String typeName); @Override void remove(TypeCategory typeCategory, String typeName); @Override void clear(); @Override IDataType onTypeFault(String typeName);  }
@Test public void testCacheHasType() throws Exception { assertTrue(cache.has(CLASSTYPE_CUSTOMER)); assertTrue(cache.has(STRUCTTYPE_ADDRESS)); assertTrue(cache.has(TRAITTYPE_PRIVILEGED)); assertTrue(cache.has(ENUMTYPE_SHIPPING)); assertFalse(cache.has(UNKNOWN_TYPE)); }
@Test public void testCacheHasTypeByCategory() throws Exception { assertTrue(cache.has(TypeCategory.CLASS, CLASSTYPE_CUSTOMER)); assertTrue(cache.has(TypeCategory.STRUCT, STRUCTTYPE_ADDRESS)); assertTrue(cache.has(TypeCategory.TRAIT, TRAITTYPE_PRIVILEGED)); assertTrue(cache.has(TypeCategory.ENUM, ENUMTYPE_SHIPPING)); assertFalse(cache.has(UNKNOWN_TYPE)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCacheHasTypeWithNullCategory() throws Exception { cache.has(null, CLASSTYPE_CUSTOMER); fail("Null TypeCategory should be not allowed in 'has'"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCacheHasTypeWithInvalidCategory() throws Exception { cache.has(TypeCategory.PRIMITIVE, DataTypes.BOOLEAN_TYPE.getName()); fail("TypeCategory should only be one of TypeCategory.CLASS | ENUM | STRUCT | TRAIT in 'has'"); }