PAN-54 Clean slate that runs
This commit is contained in:
@@ -20,7 +20,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.11'
|
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.11'
|
||||||
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.7'
|
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.7'
|
||||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
|
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
|
||||||
compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '2.0.5.RELEASE'
|
compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '2.0.5.RELEASE'
|
||||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.0.5.RELEASE'
|
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.0.5.RELEASE'
|
||||||
compile group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
|
compile group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
|
||||||
|
|||||||
@@ -39,8 +39,10 @@ class ParserService {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recurse(final Node current)
|
private void recurse(final Node current)
|
||||||
{
|
{
|
||||||
|
int startIndex;
|
||||||
|
int endIndex;
|
||||||
final String statement;
|
final String statement;
|
||||||
|
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
@@ -49,28 +51,10 @@ class ParserService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String nextStatement;
|
||||||
|
|
||||||
if(statement.contains("let"))
|
if(statement.contains("let"))
|
||||||
{
|
{
|
||||||
separateByLet(current, statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(statement.contains("if"))
|
|
||||||
{
|
|
||||||
separateByIf(current, statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(current.getStatement().contains("then"))
|
|
||||||
{
|
|
||||||
separateByThen(current, statement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void separateByLet(final Node current, final String statement){
|
|
||||||
final int startIndex;
|
|
||||||
final int endIndex;
|
|
||||||
final String nextStatement;
|
|
||||||
|
|
||||||
current.setLeft(new Node("let", current));
|
current.setLeft(new Node("let", current));
|
||||||
|
|
||||||
startIndex = statement.indexOf("let")+"let".length();
|
startIndex = statement.indexOf("let")+"let".length();
|
||||||
@@ -89,11 +73,9 @@ class ParserService {
|
|||||||
recurse(current.getLeft().getCenter());
|
recurse(current.getLeft().getCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void separateByIf(final Node current, final String statement){
|
|
||||||
final int startIndex;
|
|
||||||
final int endIndex;
|
|
||||||
final String nextStatement;
|
|
||||||
|
|
||||||
|
if(statement.contains("if"))
|
||||||
|
{
|
||||||
current.setCenter(new Node("if", current));
|
current.setCenter(new Node("if", current));
|
||||||
|
|
||||||
startIndex = statement.indexOf("if")+"if".length();
|
startIndex = statement.indexOf("if")+"if".length();
|
||||||
@@ -104,10 +86,9 @@ class ParserService {
|
|||||||
recurse(current.getCenter().getCenter());
|
recurse(current.getCenter().getCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void separateByThen(final Node current, final String statement){
|
|
||||||
final int startIndex;
|
|
||||||
final String nextStatement;
|
|
||||||
|
|
||||||
|
if(current.getStatement().contains("then"))
|
||||||
|
{
|
||||||
current.setRight(new Node("then", current));
|
current.setRight(new Node("then", current));
|
||||||
|
|
||||||
startIndex = statement.indexOf("then")+"then".length();
|
startIndex = statement.indexOf("then")+"then".length();
|
||||||
@@ -116,13 +97,14 @@ class ParserService {
|
|||||||
current.getRight().setCenter(new Node(nextStatement, current.getRight()));
|
current.getRight().setCenter(new Node(nextStatement, current.getRight()));
|
||||||
recurse(current.getRight().getCenter());
|
recurse(current.getRight().getCenter());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> retrieveStatements(final Node parsedTree)
|
public List<String> retrieveStatements(final Node parsedTree)
|
||||||
{
|
{
|
||||||
return populateStatementList(parsedTree, new ArrayList<>());
|
return populateStatementList(parsedTree, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> populateStatementList(final Node node, final ArrayList<String> statementList)
|
private ArrayList<String> populateStatementList(final Node node, final ArrayList<String> statementList)
|
||||||
{
|
{
|
||||||
if(node == null)
|
if(node == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,19 +21,7 @@ public class ParserServiceTest {
|
|||||||
@InjectMocks private ParserService parserService;
|
@InjectMocks private ParserService parserService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseRawInput_EmptyString() {
|
public void testEmptyStringEqualsEmptyString() {
|
||||||
final String expected = "0: \n";
|
|
||||||
final String actual;
|
|
||||||
|
|
||||||
when(parserService.parseRawInput("")).thenReturn(new Node("", null));
|
|
||||||
|
|
||||||
actual = parserService.parseRawInput("").toString();
|
|
||||||
|
|
||||||
assertEquals(expected, actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParseRawInputAndRecurse_EmptyStringEqualsEmptyString() {
|
|
||||||
final String expected = "0: \n";
|
final String expected = "0: \n";
|
||||||
final String actual = parserService.parseRawInput("").toString();
|
final String actual = parserService.parseRawInput("").toString();
|
||||||
|
|
||||||
@@ -41,7 +29,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseRawInput_UselessStringEqualsUselessString() {
|
public void testUselessStringEqualsUselessString() {
|
||||||
final String expected = "0: cat\n";
|
final String expected = "0: cat\n";
|
||||||
final String actual = parserService.parseRawInput("cat").toString();
|
final String actual = parserService.parseRawInput("cat").toString();
|
||||||
|
|
||||||
@@ -49,7 +37,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseRawInput_SingleIfReturnsIfPlusEmptyString() {
|
public void testSingleIfReturnsIfPlusEmptyString() {
|
||||||
final String expected = "0: if\n... 1: if\n... 2: \n\n";
|
final String expected = "0: if\n... 1: if\n... 2: \n\n";
|
||||||
final String actual = parserService.parseRawInput("if").toString();
|
final String actual = parserService.parseRawInput("if").toString();
|
||||||
|
|
||||||
@@ -57,7 +45,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseRawInput_BaseCaseIfXIsEvenThenXSquaredIsEven() {
|
public void testBaseCaseIfXIsEvenThenXSquaredIsEven() {
|
||||||
final String expected = "0: if x is even then x^2 is even\n" +
|
final String expected = "0: if x is even then x^2 is even\n" +
|
||||||
"... 1: if\n" +
|
"... 1: if\n" +
|
||||||
"... 2: x is even \n" +
|
"... 2: x is even \n" +
|
||||||
@@ -70,7 +58,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseRawInput_LetXBeEvenThenXSquaredIsEven() {
|
public void testLetXBeEvenThenXSquaredIsEven() {
|
||||||
final String expected = "0: let x be even. then x^2 is even.\n" +
|
final String expected = "0: let x be even. then x^2 is even.\n" +
|
||||||
"... 1: let\n" +
|
"... 1: let\n" +
|
||||||
"... 2: x be even. \n" +
|
"... 2: x be even. \n" +
|
||||||
@@ -83,7 +71,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseRawInput_LetIfThen() {
|
public void testLetIfThen() {
|
||||||
final String expected = "0: let a. if b, then c.\n" +
|
final String expected = "0: let a. if b, then c.\n" +
|
||||||
"... 1: let\n" +
|
"... 1: let\n" +
|
||||||
"... 2: a. \n" +
|
"... 2: a. \n" +
|
||||||
@@ -98,7 +86,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseRawInput_LetStatementWithoutAnyIfOrThenStatements() {
|
public void testLetStatementWithoutAnyIfOrThenStatements() {
|
||||||
final String expected = "0: let a be equal to b.\n" +
|
final String expected = "0: let a be equal to b.\n" +
|
||||||
"... 1: let\n" +
|
"... 1: let\n" +
|
||||||
"... 2: a be equal to b.\n\n";
|
"... 2: a be equal to b.\n\n";
|
||||||
@@ -109,7 +97,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRetrieveStatements_EmptyStringReturnsEmptyList() {
|
public void testEmptyStringReturnsEmptyList() {
|
||||||
final List<String> expectedList = new ArrayList<>();
|
final List<String> expectedList = new ArrayList<>();
|
||||||
expectedList.add("");
|
expectedList.add("");
|
||||||
|
|
||||||
@@ -120,7 +108,7 @@ public class ParserServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRetrieveStatements_BaseCaseReturnsXIsEven() {
|
public void testBaseCaseReturnsXIsEven() {
|
||||||
final List<String> expectedList = new ArrayList<>();
|
final List<String> expectedList = new ArrayList<>();
|
||||||
expectedList.add("x is even");
|
expectedList.add("x is even");
|
||||||
expectedList.add("x^2 is even");
|
expectedList.add("x^2 is even");
|
||||||
|
|||||||
@@ -9,12 +9,4 @@ public class Application {
|
|||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
SpringApplication.run(Application.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Bean
|
|
||||||
@Autowired
|
|
||||||
public UserService userService(@Autowired final RestService restService) {
|
|
||||||
return new UserService(restService);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RequestMapping("/createuser")
|
@RequestMapping("/createuser")
|
||||||
public class UserCreationController {
|
public class UserCreationController {
|
||||||
//@Autowired private final UserService userService;
|
|
||||||
|
|
||||||
@GetMapping({"/",""})
|
@GetMapping({"/",""})
|
||||||
public ModelAndView createUserPage() {
|
public ModelAndView createUserPage() {
|
||||||
LOG.info("Received request to display the user creation page: returning model with name 'User'");
|
LOG.info("Received request to display the user creation page: returning model with name 'User'");
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import static org.mockito.Mockito.mock;
|
|||||||
public class UserCreationControllerTest {
|
public class UserCreationControllerTest {
|
||||||
|
|
||||||
private final UserService userService = mock(UserService.class);
|
private final UserService userService = mock(UserService.class);
|
||||||
//@Autowired
|
|
||||||
private final UserCreationController userCreationController = new UserCreationController();//userService);
|
private final UserCreationController userCreationController = new UserCreationController();//userService);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user