### Question:
OriginManager implements LifecycleAspect { public OriginEntity saveOrigin(OriginEntity origin) { if (origin == null) return null; OriginEntity existing = getOrigin(origin.getName()); if (existing != null && !Objects.equals(existing.getId(), origin.getId()) && Objects.equals(existing.getName(), origin.getName())) { throw new IllegalArgumentException(String.format("Origin with name = %s already exists.", origin.getName())); } originDao.save(origin); originByIdCache.invalidate(origin.getId()); originByNameCache.invalidate(origin.getName()); return origin; } @Inject  OriginManager(ClusterManager clusterManager); @Override void startComponent(); @Override void stopComponent(); OriginEntity getOrigin(UUID id); OriginEntity getOrigin(String name); List<OriginEntity> fetchOrigins(); OriginEntity saveOrigin(OriginEntity origin);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testSaveOriginWithSameNameThrowsException() { getOriginManager().saveOrigin(createOrigin("origin")); getOriginManager().saveOrigin(createOrigin("origin")); }
@Test public void testSaveOriginReturnsSameEntity() { OriginEntity entity = createOrigin(); assertSame(entity, getOriginManager().saveOrigin(entity)); }
@Test public void testSaveOriginReturnsNullOnNullInput() { assertNull(getOriginManager().saveOrigin(null)); }