### Question:
OriginManager implements LifecycleAspect { public OriginEntity getOrigin(UUID id) { if (id == null) return null; try { return originByIdCache.get(id); } catch (ExecutionException ignored) { return null; } } @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 public void testSaveAndGetOriginById() { OriginEntity entity = createAndSaveOrigin(); assertOrigin(entity, getOriginManager().getOrigin(entity.getId())); }
@Test public void testGetOriginWithUnknownIdReturnsNull() { assertNull(getOriginManager().getOrigin((UUID) null)); assertNull(getOriginManager().getOrigin(UUID.randomUUID())); }
@Test public void testGetOriginByIdTwiceReturnsSameInstance() { OriginEntity entity = createAndSaveOrigin(); OriginEntity origin1 = getOriginManager().getOrigin(entity.getId()); OriginEntity origin2 = getOriginManager().getOrigin(entity.getId()); assertSame(origin1, origin2); }
@Test public void testSaveAndGetOriginByName() { OriginEntity entity = createAndSaveOrigin(); assertOrigin(entity, getOriginManager().getOrigin(entity.getName())); }
@Test public void testGetOriginWithUnknownNameReturnsNull() { assertNull(getOriginManager().getOrigin((String) null)); assertNull(getOriginManager().getOrigin("")); assertNull(getOriginManager().getOrigin("Unknown")); }
@Test public void testGetOriginByNameTwiceReturnsSameInstance() { OriginEntity entity = createAndSaveOrigin(); OriginEntity origin1 = getOriginManager().getOrigin(entity.getName()); OriginEntity origin2 = getOriginManager().getOrigin(entity.getName()); assertSame(origin1, origin2); }