private void mock() throws ParseException, ExpiredException, IOException, ProtocolException { ClientData.setUserData("Massbon", "Samu"); PowerMockito.mockStatic(ClientData.class); PowerMockito.when(ClientData.getCurrentCourse(Mockito.anyString())) .thenReturn(Optional.<Course>of(new Course())); PowerMockito.when(ClientData.getFormattedUserData()).thenReturn("Bossman:Samu"); }
@Test(expected = ProtocolException.class) public void throwsErrorIfCourseCantBeRetrieved() throws Exception { PowerMockito.when(ClientData.userDataExists()).thenReturn(true); PowerMockito.when(ClientData.getCurrentCourse(Mockito.anyString())) .thenReturn(Optional.<Course>absent()); paste.data.put("path", "asdsad"); paste.checkData(); }