@Test public void shouldGetLibraryName() throws Exception { Root root = mock(Root.class); when(viewEngine.get(Model.USER_ROOT)).thenReturn(root); when(root.getType()).thenReturn(ContainerType.LOCAL); when(messages.getMessage(anyString(), anyString())).thenReturn(""); header.initialize(viewEngine); header.initialize(); header.setMessages(messages); User user = new User(); String nickName = "Alice"; user.setNickName(nickName); when(viewEngine.get(Model.CURRENT_USER)).thenReturn(user); header.onUserSessionStarted(); verify(messages).getMessage("headerPanel.mylibrary.label", nickName); User user2 = new User(); String email = "*****@*****.**"; user2.setEmail(email); when(viewEngine.get(Model.CURRENT_USER)).thenReturn(user2); header.onUserSessionStarted(); verify(messages).getMessage("headerPanel.mylibrary.label", email); }
public void deleteSelected() { List<?> list = viewEngine.get(Model.CLIPBOARD_SELECTION); ModelCollection model = new ModelCollection(); List<Download> downloads = new ArrayList<Download>(); for (Object object : list) { if (object instanceof Download) { downloads.add((Download) object); } else { model.add(object); } } if (!downloads.isEmpty()) { deleteDownloads(downloads); } else { TrackContainer trackContainer = viewEngine.get(Model.SELECTED_CONTAINER); delete(trackContainer, model); } }
public void delete(ModelCollection model) { delete(viewEngine.get(Model.SELECTED_CONTAINER), model); }