### Question:
ObjectManager implements LifecycleAspect { public ObjectTypeEntity getObjectType(UUID id) { if (id == null) return null; try { return objectTypeByIdCache.get(id); } catch (ExecutionException ignored) { return null; } } @Inject  ObjectManager(ClusterManager clusterManager); @Override void startComponent(); @Override void stopComponent(); ObjectTypeEntity getObjectType(UUID id); ObjectTypeEntity getObjectType(String name); List<ObjectTypeEntity> fetchObjectTypes(); ObjectTypeEntity saveObjectType(ObjectTypeEntity type); ObjectEntity getObject(UUID id); ObjectEntity getObject(String type, String value); Iterator<ObjectEntity> getObjects(List<UUID> id); ObjectEntity saveObject(ObjectEntity object); Iterator<ObjectFactBindingEntity> fetchObjectFactBindings(UUID id); ObjectFactBindingEntity saveObjectFactBinding(ObjectFactBindingEntity binding);  }### Answer:
@Test public void testSaveAndGetObjectTypeById() { ObjectTypeEntity entity = createAndSaveObjectType(); assertObjectType(entity, getObjectManager().getObjectType(entity.getId())); }
@Test public void testGetObjectTypeWithUnknownIdReturnsNull() { assertNull(getObjectManager().getObjectType((UUID) null)); assertNull(getObjectManager().getObjectType(UUID.randomUUID())); }
@Test public void testGetObjectTypeByIdTwiceReturnsSameInstance() { ObjectTypeEntity entity = createAndSaveObjectType(); ObjectTypeEntity type1 = getObjectManager().getObjectType(entity.getId()); ObjectTypeEntity type2 = getObjectManager().getObjectType(entity.getId()); assertSame(type1, type2); }
@Test public void testSaveAndGetObjectTypeByName() { ObjectTypeEntity entity = createAndSaveObjectType(); assertObjectType(entity, getObjectManager().getObjectType(entity.getName())); }
@Test public void testGetObjectTypeWithUnknownNameReturnsNull() { assertNull(getObjectManager().getObjectType((String) null)); assertNull(getObjectManager().getObjectType("")); assertNull(getObjectManager().getObjectType("Unknown")); }
@Test public void testGetObjectTypeByNameTwiceReturnsSameInstance() { ObjectTypeEntity entity = createAndSaveObjectType(); ObjectTypeEntity type1 = getObjectManager().getObjectType(entity.getName()); ObjectTypeEntity type2 = getObjectManager().getObjectType(entity.getName()); assertSame(type1, type2); }