Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated getLanguageName. Added getPluginName. #23

Merged
merged 3 commits into from
Sep 13, 2015
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public AbstractLanguagePlugin(ExerciseBuilder exerciseBuilder,

public abstract ValidationResult checkCodeStyle(Path path);

@Override
public String getLanguageName() {
return getPluginName();
}

@Override
public void prepareSubmission(Path submissionPath, Path destPath) {
submissionProcessor.setStudentFilePolicy(getStudentFilePolicy(destPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@
*/
public interface LanguagePlugin {

/**
* Returns the name of the plug-in.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rm blank line

*/
String getPluginName();

/**
* Returns the name of the programming language supported by this plug-in.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rm blank line

* @return The name of the language supported by this plug-in.
*/
@Deprecated
String getLanguageName();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public RunResult runTests(Path path) {
public ValidationResult checkCodeStyle(Path path) {
return null;
}

@Override
public String getPluginName() {
return null;
}
}

private LanguagePlugin plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public AntPlugin() {
}

@Override
public String getLanguageName() {
public String getPluginName() {
return "apache-ant";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean isExerciseTypeCorrect(Path path) {
}

@Override
public String getLanguageName() {
public String getPluginName() {
return "apache-maven";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ protected StudentFilePolicy getStudentFilePolicy(Path projectPath) {
public String getLanguageName() {
return null;
}

@Override
public String getPluginName() {
return null;
}
}

private PluginImplLanguagePlugin pluginImpl;
Expand Down Expand Up @@ -111,8 +116,8 @@ public void testCheckCodeStyleWithUntestableProject() {
@Test
public void exceptionOnGetClassPathReturnsAbsentDuringScanExercise() {
Path path = TestUtils.getPath(getClass(), "trivial");
AbstractJavaPlugin plugin =
new StubLanguagePlugin(path) {
AbstractJavaPlugin plugin
= new StubLanguagePlugin(path) {
@Override
public boolean isExerciseTypeCorrect(Path path) {
return true;
Expand All @@ -129,11 +134,11 @@ protected ClassPath getProjectClassPath(Path path) throws IOException {

@Test
public void testRunnerExceptionDuringRunTestsReturnsNull() {
AbstractJavaPlugin plugin =
new StubLanguagePlugin(Paths.get("")) {
AbstractJavaPlugin plugin
= new StubLanguagePlugin(Paths.get("")) {
@Override
protected File createRunResultFile(Path path)
throws TestRunnerException, TestScannerException {
throws TestRunnerException, TestScannerException {
throw new TestRunnerException();
}
};
Expand All @@ -143,11 +148,11 @@ protected File createRunResultFile(Path path)

@Test
public void testScannerExceptionDuringRunTestsReturnsNull() {
AbstractJavaPlugin plugin =
new StubLanguagePlugin(Paths.get("")) {
AbstractJavaPlugin plugin
= new StubLanguagePlugin(Paths.get("")) {
@Override
protected File createRunResultFile(Path path)
throws TestRunnerException, TestScannerException {
throws TestRunnerException, TestScannerException {
throw new TestScannerException();
}
};
Expand All @@ -166,23 +171,23 @@ public void scanExerciseReturnsAbsentOnInvalidProject() {
public void scanExerciseAddsSourceFilesFromProject() {
Path path = TestUtils.getPath(getClass(), "trivial");
TestScanner scanner = mock(TestScanner.class);
AbstractJavaPlugin plugin =
new StubLanguagePlugin(
AbstractJavaPlugin plugin
= new StubLanguagePlugin(
Paths.get(""), new StudentFileAwareSubmissionProcessor(), scanner) {
public boolean isExerciseTypeCorrect(Path path) {
return true;
}
};
ArgumentCaptor<SourceFiles> sourceFilesCaptor = ArgumentCaptor.forClass(SourceFiles.class);
public boolean isExerciseTypeCorrect(Path path) {
return true;
}
};
ArgumentCaptor<SourceFiles> sourceFilesCaptor = ArgumentCaptor.forClass(SourceFiles.class);

plugin.scanExercise(path, "trivial");
plugin.scanExercise(path, "trivial");

verify(scanner).findTests(any(ClassPath.class), sourceFilesCaptor.capture(), anyString());
verify(scanner).findTests(any(ClassPath.class), sourceFilesCaptor.capture(), anyString());

SourceFiles sourceFiles = sourceFilesCaptor.getValue();
File expected = TestUtils.getPath(getClass(), "trivial/test/TrivialTest.java").toFile();
SourceFiles sourceFiles = sourceFilesCaptor.getValue();
File expected = TestUtils.getPath(getClass(), "trivial/test/TrivialTest.java").toFile();

assertFalse(sourceFiles.getSources().isEmpty());
assertTrue(sourceFiles.getSources().contains(expected));
assertFalse(sourceFiles.getSources().isEmpty());
assertTrue(sourceFiles.getSources().contains(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public MakePlugin() {
}

@Override
public String getLanguageName() {
public String getPluginName() {
return "make";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected StudentFilePolicy getStudentFilePolicy(Path projectPath) {
}

@Override
public String getLanguageName() {
public String getPluginName() {
return "python3";
}

Expand Down