Exemplo n.º 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");
 }
Exemplo n.º 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();
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
 }
Exemplo n.º 5
0
 @Test(expected = ProtocolException.class)
 public void throwsErrorIfNoCredentialsPresent() throws Exception {
   paste.data.put("path", "asdsad");
   ClientData.clearUserData();
   paste.checkData();
 }
Exemplo n.º 6
0
 @Test(expected = ProtocolException.class)
 public void checkDataFailIfNoAuth() throws Exception {
   ClientData.clearUserData();
   paste.checkData();
 }
Exemplo n.º 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();
 }
Exemplo n.º 8
0
 @After
 public void clean() {
   ClientData.clearUserData();
 }