UserDevfileManager { public UserDevfile getById(String id) throws NotFoundException, ServerException { requireNonNull(id); Optional<UserDevfile> result = userDevfileDao.getById(id); return result.orElseThrow( () -> new NotFoundException(format("Devfile with id '%s' doesn't exist", id))); } @Inject  UserDevfileManager(
      AccountManager accountManager, UserDevfileDao userDevfileDao, EventService eventService); UserDevfile createDevfile(UserDevfile userDevfile); UserDevfile getById(String id); Page<UserDevfile> getByNamespace(String namespace, int maxItems, long skipCount); UserDevfile updateUserDevfile(UserDevfile update); void removeUserDevfile(String id); Page<UserDevfile> getUserDevfiles(
      int maxItems,
      int skipCount,
      List<Pair<String, String>> filter,
      List<Pair<String, String>> order);  }
@Test(expectedExceptions = NullPointerException.class) public void shouldThrowNpeWhenGettingUserDevfileByNullId() throws Exception { userDevfileManager.getById(null); }
@Test public void shouldGetUserDevfileById() throws Exception { final Optional<UserDevfile> toFetch = Optional.of(createUserDevfile()); when(userDevfileDao.getById(eq("id123"))).thenReturn(toFetch); final UserDevfile fetched = userDevfileManager.getById("id123"); assertEquals(fetched, toFetch.get()); verify(userDevfileDao).getById("id123"); }
@Test( expectedExceptions = NotFoundException.class, expectedExceptionsMessageRegExp = "Devfile with id 'id123' doesn't exist") public void shouldThrowNotFoundExceptionOnGetUserDevfileByIdIfNotFound() throws Exception { doReturn(Optional.empty()).when(userDevfileDao).getById(eq("id123")); userDevfileManager.getById("id123"); }