fix compile
This commit is contained in:
parent
162b0e7744
commit
264d3a781a
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
package com.primefactorsolutions.service;
|
||||
|
||||
import com.primefactorsolutions.service.compiler.InMemoryClass;
|
||||
import com.primefactorsolutions.service.compiler.InMemoryFileManager;
|
||||
import com.primefactorsolutions.service.compiler.JavaSourceFromString;
|
||||
import lombok.SneakyThrows;
|
||||
@ -11,6 +10,7 @@ import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.ToolProvider;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -44,8 +44,15 @@ public class CompilerService {
|
||||
} else {
|
||||
final ClassLoader classLoader = manager.getClassLoader(null);
|
||||
final Class<?> clazz = classLoader.loadClass(qualifiedClassName);
|
||||
final InMemoryClass instanceOfClass = (InMemoryClass) clazz.newInstance();
|
||||
final Map<String, Boolean> results = instanceOfClass.runCode();
|
||||
Map<String, Boolean> results = Map.of();
|
||||
|
||||
Method[] methods = clazz.getMethods();
|
||||
for (Method m : methods) {
|
||||
if ("run".equals(m.getName())) {
|
||||
results = (Map<String, Boolean>) m.invoke(null, new Object[] {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.of(results.entrySet().stream()
|
||||
.map(e -> String.format("%-50s ... %4s", e.getKey(), RESULT_MESSAGE.get(e.getValue())))
|
||||
|
@ -301,13 +301,12 @@ public class EvaluationView extends Main implements HasUrlParameter<String> {
|
||||
questionEditor.setSofttabs(true);
|
||||
questionEditor.setTabSize(4);
|
||||
questionEditor.setWrap(true);
|
||||
questionEditor.setMinlines(20);
|
||||
questionEditor.setMaxlines(30);
|
||||
// aceEditor.setPlaceholder("... Edit ...");
|
||||
questionEditor.setAutoComplete(true);
|
||||
questionEditor.setCustomAutoCompletion(new String[] { "TEST", "TEST2", "TEST3" });
|
||||
questionEditor.setMinlines(60);
|
||||
questionEditor.setMaxlines(80);
|
||||
questionEditor.setAutoComplete(false);
|
||||
questionEditor.setHighlightActiveLine(true);
|
||||
questionEditor.setHighlightSelectedWord(false);
|
||||
|
||||
return questionEditor;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.primefactorsolutions;
|
||||
|
||||
import com.primefactorsolutions.service.compiler.InMemoryClass;
|
||||
import java.util.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TestClass implements InMemoryClass {
|
||||
public class TestClass {
|
||||
|
||||
// ------------ IMPLEMENTAR AQUI --------------------------------
|
||||
|
||||
@ -37,8 +36,7 @@ public class TestClass implements InMemoryClass {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> runCode() {
|
||||
public static Map<String, Boolean> run() {
|
||||
Map<String, Boolean> results = Arrays.stream(Tests.class.getDeclaredMethods())
|
||||
.map(m -> {
|
||||
try {
|
||||
|
46
src/main/resources/questions/foobar.java.txt
Normal file
46
src/main/resources/questions/foobar.java.txt
Normal file
@ -0,0 +1,46 @@
|
||||
package com.primefactorsolutions;
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TestClass {
|
||||
|
||||
// ------------ IMPLEMENTAR AQUI --------------------------------
|
||||
|
||||
public static String getFooBar(int N) {
|
||||
return "TODO";
|
||||
}
|
||||
|
||||
|
||||
// ------------- NO MODIFICAR DESDE ESTA LINEA --------------------
|
||||
|
||||
public static class Tests {
|
||||
public static Map.Entry<String, Boolean> testNInvalido() {
|
||||
boolean result = getFooBar(-1).equals("");
|
||||
|
||||
return Map.entry("N invalido retorna vacio", result);
|
||||
}
|
||||
|
||||
public static Map.Entry<String, Boolean> testNValido() {
|
||||
boolean result = getFooBar(7).equals("1,Foo,Bar,Foo,5,FooBar,7");
|
||||
|
||||
return Map.entry("N valido correcto", result);
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Boolean> run() {
|
||||
Map<String, Boolean> results = Arrays.stream(Tests.class.getDeclaredMethods())
|
||||
.map(m -> {
|
||||
try {
|
||||
return (Map.Entry<String, Boolean>) m.invoke(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
package com.primefactorsolutions;
|
||||
|
||||
import com.primefactorsolutions.service.compiler.InMemoryClass;
|
||||
import java.util.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TestClass implements InMemoryClass {
|
||||
public class TestClass {
|
||||
|
||||
// ------------ IMPLEMENTAR AQUI --------------------------------
|
||||
|
||||
@ -30,9 +29,15 @@ public class TestClass implements InMemoryClass {
|
||||
}
|
||||
|
||||
public static Map.Entry<String, Boolean> testPalindromaUnico() {
|
||||
boolean result = getPalindroma("z").equals("ZZ");
|
||||
boolean result = getPalindroma("z").equals("Z");
|
||||
|
||||
return Map.entry("palindrome una solo caracter es valido", result);
|
||||
return Map.entry("palindrome un solo caracter es valido", result);
|
||||
}
|
||||
|
||||
public static Map.Entry<String, Boolean> testPalindromaUnico() {
|
||||
boolean result = getPalindroma("abba").equals("ABBA");
|
||||
|
||||
return Map.entry("palindrome un solo caracter es valido", result);
|
||||
}
|
||||
|
||||
public static Map.Entry<String, Boolean> testPalindromaNull() {
|
||||
@ -42,8 +47,7 @@ public class TestClass implements InMemoryClass {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> runCode() {
|
||||
public static Map<String, Boolean> run() {
|
||||
Map<String, Boolean> results = Arrays.stream(Tests.class.getDeclaredMethods())
|
||||
.map(m -> {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user