Skip to content

Commit

Permalink
fix indentation and import orders
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthKipsu authored and wakr committed Sep 12, 2015
1 parent 19cc94f commit c8f842c
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public UrlHelper(TmcSettings settings) {

public URI getCourseUrl(int courseId) throws URISyntaxException {
return withParams(URI.create(
settings.getServerAddress() + "/courses/" + courseId + ".json"));
settings.getServerAddress() + "/courses/" + courseId + ".json"));
}

public URI getCourseUrl(Course course) throws URISyntaxException {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fi/helsinki/cs/tmc/core/domain/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class Exercise implements Serializable {
private URI returnUrl;

@SerializedName("zip_url")
private URI zipUrl;
private URI zipUrl; //": "https://tmc.mooc.fi/staging/exercises/284.zip",

/**
* The URL the solution can be downloaded from (admins only).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void setUp() {
settings = new CoreTestSettings();
serverAddress += wireMock.port();
command = new SendFeedback(settings,
testCaseMap(),
URI.create(serverAddress + "/feedback"));
testCaseMap(),
URI.create(serverAddress + "/feedback"));
}

private Map<String, String> testCaseMap() {
Expand Down Expand Up @@ -64,12 +64,12 @@ public void testCallSendsFeedbackToServer() throws Exception {

Course currentCourse = new Course();
currentCourse.setSpywareUrls(Collections.singletonList(
URI.create(serverAddress + "/spyware")));
URI.create(serverAddress + "/spyware")));
settings.setCurrentCourse(currentCourse);

command = new SendFeedback(settings,
testCaseMap(),
URI.create(serverAddress + "/feedback"));
testCaseMap(),
URI.create(serverAddress + "/feedback"));

command.call();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


import fi.helsinki.cs.tmc.core.CoreTestSettings;
import fi.helsinki.cs.tmc.core.TmcCore;
import fi.helsinki.cs.tmc.core.communication.ExerciseSubmitter;
Expand Down Expand Up @@ -47,7 +46,6 @@

public class SubmitTest {


private Submit submit;
private ExerciseSubmitter submitterMock;
private CoreTestSettings settings;
Expand Down Expand Up @@ -116,7 +114,7 @@ public void setup() throws Exception {
path = Paths.get("polku", "kurssi", "kansioon", "src").toString();

when(submitterMock.submit(anyString()))
.thenReturn(URI.create(serverAddress + submissionUrl));
.thenReturn(URI.create(serverAddress + submissionUrl));
submit =
new Submit(
settings, submitterMock, new SubmissionPoller(new TmcApi(settings)), path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import static org.junit.Assert.assertTrue;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

Expand Down Expand Up @@ -38,8 +40,6 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.eq;

public class ExerciseDownloaderTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package fi.helsinki.cs.tmc.core.communication;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import fi.helsinki.cs.tmc.core.CoreTestSettings;
import fi.helsinki.cs.tmc.core.domain.Course;
import fi.helsinki.cs.tmc.core.domain.ProgressObserver;
Expand All @@ -9,11 +18,11 @@
import fi.helsinki.cs.tmc.core.testhelpers.ProjectRootFinderStub;
import fi.helsinki.cs.tmc.core.zipping.ProjectRootFinder;
import fi.helsinki.cs.tmc.langs.util.TaskExecutorImpl;

import com.google.common.base.Optional;
import fi.helsinki.cs.tmc.langs.domain.NoLanguagePluginFoundException;
import fi.helsinki.cs.tmc.langs.util.TaskExecutor;

import com.google.common.base.Optional;

import org.junit.Before;
import org.junit.Test;

Expand All @@ -29,16 +38,6 @@
import java.text.ParseException;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class ExerciseSubmitterTest {

private ExerciseSubmitter courseSubmitter;
Expand Down Expand Up @@ -267,10 +266,10 @@ public void submitWithCodeReviewRequest()
rootFinder.setReturnValue(testPath.toString());
courseSubmitter.submitWithCodeReviewRequest(testPath, "Help");
Mockito.verify(urlCommunicator)
.makePostWithByteArray(Mockito.any(URI.class),
any(byte[].class),
anyMap(),
capture.capture());
.makePostWithByteArray(Mockito.any(URI.class),
any(byte[].class),
anyMap(),
capture.capture());
assertEquals("1", capture.getValue().get("request_review"));
assertEquals("Help", capture.getValue().get("message_for_reviewer"));
}
Expand All @@ -295,9 +294,9 @@ public void submitWithCodeReviewRequestWithEmptyMessage()
courseSubmitter.submitWithCodeReviewRequest(testPath, "");
Mockito.verify(urlCommunicator)
.makePostWithByteArray(Mockito.any(URI.class),
any(byte[].class),
anyMap(),
capture.capture());
any(byte[].class),
anyMap(),
capture.capture());
assertEquals("1", capture.getValue().get("request_review"));
assertNull(capture.getValue().get("message_for_reviewer"));
}
Expand Down Expand Up @@ -329,10 +328,10 @@ private void mockUrlCommunicator(String pieceOfUrl, String returnValue) throws I
HttpResult fakeResult = new HttpResult(returnValue, 200, true);

Mockito.when(urlCommunicator.makeGetRequest(
Mockito.argThat(new UriContains(pieceOfUrl)), Mockito.anyString()))
Mockito.argThat(new UriContains(pieceOfUrl)), Mockito.anyString()))
.thenReturn(fakeResult);
Mockito.when(urlCommunicator.makeGetRequestWithAuthentication(
Mockito.argThat(new UriContains(pieceOfUrl))))
Mockito.argThat(new UriContains(pieceOfUrl))))
.thenReturn(fakeResult);
}

Expand All @@ -346,6 +345,5 @@ private void mockUrlCommunicatorWithFile(String url, String returnValue) throws
Mockito.any(Map.class),
Mockito.any(Map.class)))
.thenReturn(fakeResult);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ public class SubmissionPollerTest {

private SubmissionPoller submissionPoller;
private URI url = URI.create(
<<<<<<< HEAD
"https://example.com/staging/submissions/1764.json?api_version=7&client=tmc_cli&client_version=1");
=======
"https://tmc.mooc.fi/staging/submissions/1764.json?api_version=7&client=tmc_cli&client_version=1");
>>>>>>> fix indentation and import orders
private CoreTestSettings settings;
private TmcApi tmcApi;

Expand Down Expand Up @@ -76,6 +80,6 @@ private void mockPolling() throws IOException {
String success = ExampleJson.successfulSubmission;

when(tmcApi.getRawTextFrom(any(URI.class)))
.thenReturn(first, second, placeChange, success);
.thenReturn(first, second, placeChange, success);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void parsesSubmissionUrlFromJson() throws IOException {
public void parsesPasteUrlFromJson() throws IOException, TmcCoreException {
HttpResult fakeResult = new HttpResult(ExampleJson.pasteResponse, 200, true);
Mockito.when(urlCommunicator.makeGetRequest(URI.create(Mockito.anyString()),
Mockito.anyString()))
Mockito.anyString()))
.thenReturn(fakeResult);
assertEquals(
URI.create("https://example.com/staging/paste/ynpw7_mZZGk3a9PPrMWOOQ"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
* Custom argument matcher for testing URI substring.
*/
public class UriContains extends ArgumentMatcher<URI> {
private final String search;

public UriContains(String search) {
this.search = search;
}

@Override
public boolean matches(Object argument) {
if (argument == null) {
return search == null;
}
return argument.toString().contains(search);
}
private final String search;
public UriContains(String search) {
this.search = search;
}
@Override
public boolean matches(Object argument) {
if (argument == null) {
return search == null;
}
return argument.toString().contains(search);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public void okWithValidParams() throws IOException, TmcCoreException {
@Test
public void badRequestWithoutValidUrl() throws IOException, TmcCoreException {
HttpResult result = urlCommunicator.makeGetRequest(
URI.create(serverAddress + "/vaaraurl"),
"test:1234");
URI.create(serverAddress + "/vaaraurl"),
"test:1234");
assertEquals(400, result.getStatusCode());
}

Expand Down Expand Up @@ -137,8 +137,8 @@ public void makePutRequestSendsPut() throws IOException, TmcCoreException, URISy
Map<String, String> body = new HashMap<>();
body.put("mark_as_read", "1");
HttpResult makePutRequest = urlCommunicator.makePutRequest(
URI.create(serverAddress + "/putty"),
Optional.of(body));
URI.create(serverAddress + "/putty"),
Optional.of(body));
assertEquals(200, makePutRequest.getStatusCode());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class ReviewTest {

private static final URI updateUrl =
URI.create("http://test.mooc.duck.fi/courses/47/reviews/8");
URI.create("http://test.mooc.duck.fi/courses/47/reviews/8");
private static final URI putUrl = URI.create(updateUrl + ".json?api_version=7");
private Review review;

Expand Down

0 comments on commit c8f842c

Please sign in to comment.