### Question:
ObjectManager implements LifecycleAspect { public ObjectEntity saveObject(ObjectEntity object) { if (object == null) return null; ObjectTypeEntity type = getObjectType(object.getTypeID()); if (type == null) throw new IllegalArgumentException(String.format("ObjectType with id = %s does not exist.", object.getTypeID())); if (getObject(type.getName(), object.getValue()) != null) { throw new ImmutableViolationException("Object already exists."); } ObjectByTypeValueEntity objectByTypeValue = new ObjectByTypeValueEntity() .setObjectTypeID(object.getTypeID()) .setObjectValue(object.getValue()) .setObjectID(object.getId()); objectDao.save(object); objectDao.save(objectByTypeValue); return object; } @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(expected = IllegalArgumentException.class) public void testSaveObjectWithNonExistingObjectType() { getObjectManager().saveObject(createObject()); }
@Test(expected = ImmutableViolationException.class) public void testSaveSameObjectTwice() { ObjectTypeEntity type = createAndSaveObjectType(); ObjectEntity object = createObject(type.getId()); getObjectManager().saveObject(object); getObjectManager().saveObject(object); }
@Test public void testSaveObjectReturnsSameEntity() { ObjectEntity entity = createObject(createAndSaveObjectType().getId()); assertSame(entity, getObjectManager().saveObject(entity)); }
@Test public void testSaveObjectReturnsNullOnNullInput() { assertNull(getObjectManager().saveObject(null)); }