diff --git a/src/main/java/fi/helsinki/cs/tmc/core/communication/UrlHelper.java b/src/main/java/fi/helsinki/cs/tmc/core/communication/UrlHelper.java index 2caec4e0..b741ee96 100644 --- a/src/main/java/fi/helsinki/cs/tmc/core/communication/UrlHelper.java +++ b/src/main/java/fi/helsinki/cs/tmc/core/communication/UrlHelper.java @@ -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 { diff --git a/src/main/java/fi/helsinki/cs/tmc/core/domain/Exercise.java b/src/main/java/fi/helsinki/cs/tmc/core/domain/Exercise.java index 0e38665d..cd5ed60f 100644 --- a/src/main/java/fi/helsinki/cs/tmc/core/domain/Exercise.java +++ b/src/main/java/fi/helsinki/cs/tmc/core/domain/Exercise.java @@ -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). */ diff --git a/src/test/java/fi/helsinki/cs/tmc/core/commands/SendFeedbackTest.java b/src/test/java/fi/helsinki/cs/tmc/core/commands/SendFeedbackTest.java index 35fc8596..a82d2a38 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/commands/SendFeedbackTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/commands/SendFeedbackTest.java @@ -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 testCaseMap() { @@ -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(); diff --git a/src/test/java/fi/helsinki/cs/tmc/core/commands/SubmitTest.java b/src/test/java/fi/helsinki/cs/tmc/core/commands/SubmitTest.java index 7004db74..a3a10f5c 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/commands/SubmitTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/commands/SubmitTest.java @@ -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; @@ -47,7 +46,6 @@ public class SubmitTest { - private Submit submit; private ExerciseSubmitter submitterMock; private CoreTestSettings settings; @@ -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); diff --git a/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseDownloaderTest.java b/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseDownloaderTest.java index a02fdccf..9cc52cb8 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseDownloaderTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseDownloaderTest.java @@ -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; @@ -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 { diff --git a/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseSubmitterTest.java b/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseSubmitterTest.java index 70247e78..02b2e3de 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseSubmitterTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/communication/ExerciseSubmitterTest.java @@ -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; @@ -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; @@ -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; @@ -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")); } @@ -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")); } @@ -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); } @@ -346,6 +345,5 @@ private void mockUrlCommunicatorWithFile(String url, String returnValue) throws Mockito.any(Map.class), Mockito.any(Map.class))) .thenReturn(fakeResult); - } } diff --git a/src/test/java/fi/helsinki/cs/tmc/core/communication/SubmissionPollerTest.java b/src/test/java/fi/helsinki/cs/tmc/core/communication/SubmissionPollerTest.java index d5e209c6..b48c3550 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/communication/SubmissionPollerTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/communication/SubmissionPollerTest.java @@ -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; @@ -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); } } diff --git a/src/test/java/fi/helsinki/cs/tmc/core/communication/TmcApiTest.java b/src/test/java/fi/helsinki/cs/tmc/core/communication/TmcApiTest.java index 79c73d9f..2689f78e 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/communication/TmcApiTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/communication/TmcApiTest.java @@ -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"), diff --git a/src/test/java/fi/helsinki/cs/tmc/core/communication/UriContains.java b/src/test/java/fi/helsinki/cs/tmc/core/communication/UriContains.java index d7541104..196dcf9e 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/communication/UriContains.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/communication/UriContains.java @@ -7,17 +7,17 @@ * Custom argument matcher for testing URI substring. */ public class UriContains extends ArgumentMatcher { - 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); + } } diff --git a/src/test/java/fi/helsinki/cs/tmc/core/communication/UrlCommunicatorTest.java b/src/test/java/fi/helsinki/cs/tmc/core/communication/UrlCommunicatorTest.java index 9201ac87..e7f2f056 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/communication/UrlCommunicatorTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/communication/UrlCommunicatorTest.java @@ -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()); } @@ -137,8 +137,8 @@ public void makePutRequestSendsPut() throws IOException, TmcCoreException, URISy Map 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()); } diff --git a/src/test/java/fi/helsinki/cs/tmc/core/domain/ReviewTest.java b/src/test/java/fi/helsinki/cs/tmc/core/domain/ReviewTest.java index f19d5fc9..1f8490d9 100644 --- a/src/test/java/fi/helsinki/cs/tmc/core/domain/ReviewTest.java +++ b/src/test/java/fi/helsinki/cs/tmc/core/domain/ReviewTest.java @@ -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;