예제 #1
0
 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");
 }
예제 #2
0
 @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();
 }
예제 #3
0
 /** Mocks CourseSubmitter and injects it into Paste command. */
 @Before
 public void setup() throws Exception {
   Mailbox.create();
   mock();
   ClientData.setUserData("Bossman", "Samu");
   ClientData.setProjectRootFinder(new ProjectRootFinderStub());
   TmcServiceScheduler.disablePolling();
   submitterMock = Mockito.mock(CourseSubmitter.class);
   when(submitterMock.submitPaste(Mockito.anyString())).thenReturn(pasteUrl);
   paste = new Paste(submitterMock);
 }
예제 #4
0
 @Test
 public void submitReturnsBadOutputWhenCodeIsBad() throws Exception {
   PowerMockito.when(ClientData.userDataExists()).thenReturn(true);
   paste.setParameter("path", "/hieno/path");
   String result = paste.parseData(paste.call()).get();
   assertTrue(result.contains(pasteUrl));
 }
예제 #5
0
 @Test(expected = ProtocolException.class)
 public void throwsErrorIfNoCredentialsPresent() throws Exception {
   paste.data.put("path", "asdsad");
   ClientData.clearUserData();
   paste.checkData();
 }
예제 #6
0
 @Test(expected = ProtocolException.class)
 public void checkDataFailIfNoAuth() throws Exception {
   ClientData.clearUserData();
   paste.checkData();
 }
예제 #7
0
 /** Check that data checking success. */
 @Test
 public void testCheckDataSuccess() throws ProtocolException, IOException {
   PowerMockito.when(ClientData.userDataExists()).thenReturn(true);
   paste.setParameter("path", "/home/tmccli/uolevipuistossa");
   paste.checkData();
 }
예제 #8
0
 @After
 public void clean() {
   ClientData.clearUserData();
 }