@Test public void testBeanAsRegularJava(){ UserBean bean = new UserBean(); assertThrows(NullPointerException.class, () -> bean.registerNewUser("a","b","c")); }
public void registerNewUser(@NotNull String userId, @NotNull String name, @NotNull String surname){ if(isRegistered(userId)){ return; } User user = new User(); user.setUserId(userId); user.setName(name); user.setSurname(surname); em.persist(user); }
UserBean { public void registerNewUser(@NotNull String userId, @NotNull String name, @NotNull String surname){ if(isRegistered(userId)){ return; } User user = new User(); user.setUserId(userId); user.setName(name); user.setSurname(surname); em.persist(user); } }
UserBean { public void registerNewUser(@NotNull String userId, @NotNull String name, @NotNull String surname){ if(isRegistered(userId)){ return; } User user = new User(); user.setUserId(userId); user.setName(name); user.setSurname(surname); em.persist(user); } UserBean(); }
UserBean { public void registerNewUser(@NotNull String userId, @NotNull String name, @NotNull String surname){ if(isRegistered(userId)){ return; } User user = new User(); user.setUserId(userId); user.setName(name); user.setSurname(surname); em.persist(user); } UserBean(); void registerNewUser(@NotNull String userId, @NotNull String name, @NotNull String surname); boolean isRegistered(@NotNull String userId); long getNumberOfUsers(); }
UserBean { public void registerNewUser(@NotNull String userId, @NotNull String name, @NotNull String surname){ if(isRegistered(userId)){ return; } User user = new User(); user.setUserId(userId); user.setName(name); user.setSurname(surname); em.persist(user); } UserBean(); void registerNewUser(@NotNull String userId, @NotNull String name, @NotNull String surname); boolean isRegistered(@NotNull String userId); long getNumberOfUsers();  }