@Test public void getUser() { providePrinciple(new User("user", "", emptyList())); CoffeeNetUserDetails coffeeNetUserDetails = sut.get().get(); assertThat(coffeeNetUserDetails, instanceOf(HumanCoffeeNetUser.class)); assertThat(coffeeNetUserDetails.getEmail(), is("user@coffeenet")); assertThat(coffeeNetUserDetails.getUsername(), is("user")); assertThat(coffeeNetUserDetails.getAuthorities(), hasSize(0)); }
@Override public Optional<CoffeeNetUserDetails> get() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return Optional.empty(); } User user = (User) authentication.getPrincipal(); return getCoffeeNetUserDetails(user); }
DevelopmentCoffeeNetCurrentUserService implements CoffeeNetCurrentUserService { @Override public Optional<CoffeeNetUserDetails> get() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return Optional.empty(); } User user = (User) authentication.getPrincipal(); return getCoffeeNetUserDetails(user); } }
DevelopmentCoffeeNetCurrentUserService implements CoffeeNetCurrentUserService { @Override public Optional<CoffeeNetUserDetails> get() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return Optional.empty(); } User user = (User) authentication.getPrincipal(); return getCoffeeNetUserDetails(user); }  }
DevelopmentCoffeeNetCurrentUserService implements CoffeeNetCurrentUserService { @Override public Optional<CoffeeNetUserDetails> get() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return Optional.empty(); } User user = (User) authentication.getPrincipal(); return getCoffeeNetUserDetails(user); }  @Override Optional<CoffeeNetUserDetails> get(); }
DevelopmentCoffeeNetCurrentUserService implements CoffeeNetCurrentUserService { @Override public Optional<CoffeeNetUserDetails> get() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return Optional.empty(); } User user = (User) authentication.getPrincipal(); return getCoffeeNetUserDetails(user); }  @Override Optional<CoffeeNetUserDetails> get();  }