PAN-57 Refacted superfluous code
This commit is contained in:
+12
-12
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence;
|
package edu.msudenver.tsp.persistence;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.AccountDto;
|
import edu.msudenver.tsp.persistence.dto.Account;
|
||||||
import edu.msudenver.tsp.persistence.repository.AccountsRepository;
|
import edu.msudenver.tsp.persistence.repository.AccountsRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -19,8 +19,8 @@ public class AccountsIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRUDFunctionality() {
|
public void testCRUDFunctionality() {
|
||||||
final AccountDto accountDto = createAccount();
|
final Account account = createAccount();
|
||||||
final AccountDto savedAccount = accountsRepository.save(accountDto);
|
final Account savedAccount = accountsRepository.save(account);
|
||||||
|
|
||||||
assertNotNull(savedAccount);
|
assertNotNull(savedAccount);
|
||||||
assertEquals(Integer.valueOf(0), savedAccount.getVersion());
|
assertEquals(Integer.valueOf(0), savedAccount.getVersion());
|
||||||
@@ -33,25 +33,25 @@ public class AccountsIntegrationTest {
|
|||||||
|
|
||||||
savedAccount.setPassword("Test Update");
|
savedAccount.setPassword("Test Update");
|
||||||
|
|
||||||
final AccountDto updatedAccount = accountsRepository.save(savedAccount);
|
final Account updatedAccount = accountsRepository.save(savedAccount);
|
||||||
|
|
||||||
assertEquals("Test username", savedAccount.getUsername());
|
assertEquals("Test username", savedAccount.getUsername());
|
||||||
assertEquals("Test Update", savedAccount.getPassword());
|
assertEquals("Test Update", savedAccount.getPassword());
|
||||||
assertTrue(savedAccount.getAdministratorStatus());
|
assertTrue(savedAccount.getAdministratorStatus());
|
||||||
assertEquals(updatedAccount.getId(), id);
|
assertEquals(updatedAccount.getId(), id);
|
||||||
|
|
||||||
accountsRepository.delete(accountDto);
|
accountsRepository.delete(account);
|
||||||
final Optional<AccountDto> deletedAccount = accountsRepository.findById(id);
|
final Optional<Account> deletedAccount = accountsRepository.findById(id);
|
||||||
assertFalse(deletedAccount.isPresent());
|
assertFalse(deletedAccount.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccountDto createAccount() {
|
private Account createAccount() {
|
||||||
final AccountDto accountDto = new AccountDto();
|
final Account account = new Account();
|
||||||
accountDto.setUsername("Test username");
|
account.setUsername("Test username");
|
||||||
accountDto.setPassword("test password");
|
account.setPassword("test password");
|
||||||
accountDto.setAdministratorStatus(true);
|
account.setAdministratorStatus(true);
|
||||||
|
|
||||||
return accountDto;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence;
|
package edu.msudenver.tsp.persistence;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.DefinitionDto;
|
import edu.msudenver.tsp.persistence.dto.Definition;
|
||||||
import edu.msudenver.tsp.persistence.repository.DefinitionRepository;
|
import edu.msudenver.tsp.persistence.repository.DefinitionRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -21,8 +21,8 @@ public class DefinitionsIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRUDFunctionality() {
|
public void testCRUDFunctionality() {
|
||||||
final DefinitionDto definitionDto = createDefinition();
|
final Definition definition = createDefinition();
|
||||||
final DefinitionDto savedDefinition = definitionRepository.save(definitionDto);
|
final Definition savedDefinition = definitionRepository.save(definition);
|
||||||
|
|
||||||
assertNotNull(savedDefinition);
|
assertNotNull(savedDefinition);
|
||||||
assertEquals(Integer.valueOf(0), savedDefinition.getVersion());
|
assertEquals(Integer.valueOf(0), savedDefinition.getVersion());
|
||||||
@@ -44,7 +44,7 @@ public class DefinitionsIntegrationTest {
|
|||||||
|
|
||||||
savedDefinition.setName("Test Update");
|
savedDefinition.setName("Test Update");
|
||||||
|
|
||||||
final DefinitionDto updatedDefinition = definitionRepository.save(savedDefinition);
|
final Definition updatedDefinition = definitionRepository.save(savedDefinition);
|
||||||
|
|
||||||
assertEquals("Test Update", updatedDefinition.getName());
|
assertEquals("Test Update", updatedDefinition.getName());
|
||||||
assertNotNull(updatedDefinition.getDefinition());
|
assertNotNull(updatedDefinition.getDefinition());
|
||||||
@@ -61,11 +61,11 @@ public class DefinitionsIntegrationTest {
|
|||||||
assertEquals(id, updatedDefinition.getId());
|
assertEquals(id, updatedDefinition.getId());
|
||||||
|
|
||||||
definitionRepository.delete(updatedDefinition);
|
definitionRepository.delete(updatedDefinition);
|
||||||
final Optional<DefinitionDto> deletedDefinition = definitionRepository.findById(id);
|
final Optional<Definition> deletedDefinition = definitionRepository.findById(id);
|
||||||
assertFalse(deletedDefinition.isPresent());
|
assertFalse(deletedDefinition.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefinitionDto createDefinition() {
|
private Definition createDefinition() {
|
||||||
final List<String> definitionList = new ArrayList<>();
|
final List<String> definitionList = new ArrayList<>();
|
||||||
definitionList.add("Test definition 1");
|
definitionList.add("Test definition 1");
|
||||||
definitionList.add("Test definition 2");
|
definitionList.add("Test definition 2");
|
||||||
@@ -73,11 +73,11 @@ public class DefinitionsIntegrationTest {
|
|||||||
final List<String> notationList = new ArrayList<>();
|
final List<String> notationList = new ArrayList<>();
|
||||||
notationList.add("\\testLaTeX");
|
notationList.add("\\testLaTeX");
|
||||||
|
|
||||||
final DefinitionDto definitionDto = new DefinitionDto();
|
final Definition definition = new Definition();
|
||||||
definitionDto.setName("Test Name");
|
definition.setName("Test Name");
|
||||||
definitionDto.setDefinition(definitionList);
|
definition.setDefinition(definitionList);
|
||||||
definitionDto.setNotation(notationList);
|
definition.setNotation(notationList);
|
||||||
|
|
||||||
return definitionDto;
|
return definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence;
|
package edu.msudenver.tsp.persistence;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.ProofDto;
|
import edu.msudenver.tsp.persistence.dto.Proof;
|
||||||
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -23,8 +23,8 @@ public class ProofsIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRUDFunctionality() {
|
public void testCRUDFunctionality() {
|
||||||
final ProofDto proofDto = createProof();
|
final Proof proof = createProof();
|
||||||
final ProofDto savedProof = proofRepository.save(proofDto);
|
final Proof savedProof = proofRepository.save(proof);
|
||||||
|
|
||||||
assertNotNull(savedProof);
|
assertNotNull(savedProof);
|
||||||
assertEquals(Integer.valueOf(0), savedProof.getVersion());
|
assertEquals(Integer.valueOf(0), savedProof.getVersion());
|
||||||
@@ -44,7 +44,7 @@ public class ProofsIntegrationTest {
|
|||||||
|
|
||||||
savedProof.setBranch("Test Update");
|
savedProof.setBranch("Test Update");
|
||||||
|
|
||||||
final ProofDto updatedProof = proofRepository.save(savedProof);
|
final Proof updatedProof = proofRepository.save(savedProof);
|
||||||
|
|
||||||
assertNotNull(updatedProof);
|
assertNotNull(updatedProof);
|
||||||
assertEquals(Integer.valueOf(0), updatedProof.getVersion());
|
assertEquals(Integer.valueOf(0), updatedProof.getVersion());
|
||||||
@@ -61,12 +61,12 @@ public class ProofsIntegrationTest {
|
|||||||
assertEquals("test definition 2", updatedProof.getReferencedDefinitions().get(1));
|
assertEquals("test definition 2", updatedProof.getReferencedDefinitions().get(1));
|
||||||
assertEquals(updatedProof.getId(), id);
|
assertEquals(updatedProof.getId(), id);
|
||||||
|
|
||||||
proofRepository.delete(proofDto);
|
proofRepository.delete(proof);
|
||||||
final Optional<ProofDto> deletedProof = proofRepository.findById(id);
|
final Optional<Proof> deletedProof = proofRepository.findById(id);
|
||||||
assertFalse(deletedProof.isPresent());
|
assertFalse(deletedProof.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProofDto createProof() {
|
private Proof createProof() {
|
||||||
final List<String> referencedTheoremsList = new ArrayList<>();
|
final List<String> referencedTheoremsList = new ArrayList<>();
|
||||||
referencedTheoremsList.add("test theorem 1");
|
referencedTheoremsList.add("test theorem 1");
|
||||||
referencedTheoremsList.add("test theorem 2");
|
referencedTheoremsList.add("test theorem 2");
|
||||||
@@ -75,13 +75,13 @@ public class ProofsIntegrationTest {
|
|||||||
referencedDefinitionsList.add("test definition 1");
|
referencedDefinitionsList.add("test definition 1");
|
||||||
referencedDefinitionsList.add("test definition 2");
|
referencedDefinitionsList.add("test definition 2");
|
||||||
|
|
||||||
final ProofDto proofDto = new ProofDto();
|
final Proof proof = new Proof();
|
||||||
proofDto.setTheoremName("Test proof");
|
proof.setTheoremName("Test proof");
|
||||||
proofDto.setBranch("Test branch");
|
proof.setBranch("Test branch");
|
||||||
proofDto.setDateCreated(new Date());
|
proof.setDateCreated(new Date());
|
||||||
proofDto.setReferencedTheorems(referencedTheoremsList);
|
proof.setReferencedTheorems(referencedTheoremsList);
|
||||||
proofDto.setReferencedDefinitions(referencedDefinitionsList);
|
proof.setReferencedDefinitions(referencedDefinitionsList);
|
||||||
|
|
||||||
return proofDto;
|
return proof;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence;
|
package edu.msudenver.tsp.persistence;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.TheoremDto;
|
import edu.msudenver.tsp.persistence.dto.Theorem;
|
||||||
import edu.msudenver.tsp.persistence.dto.TheoremType;
|
import edu.msudenver.tsp.persistence.dto.TheoremType;
|
||||||
import edu.msudenver.tsp.persistence.repository.TheoremRepository;
|
import edu.msudenver.tsp.persistence.repository.TheoremRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -22,8 +22,8 @@ public class TheoremsIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCRUDFunctionality() {
|
public void testCRUDFunctionality() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theorem = createTheorem();
|
||||||
final TheoremDto savedTheorem = theoremRepository.save(theoremDto);
|
final Theorem savedTheorem = theoremRepository.save(theorem);
|
||||||
|
|
||||||
assertNotNull(savedTheorem);
|
assertNotNull(savedTheorem);
|
||||||
assertEquals(Integer.valueOf(0), savedTheorem.getVersion());
|
assertEquals(Integer.valueOf(0), savedTheorem.getVersion());
|
||||||
@@ -42,7 +42,7 @@ public class TheoremsIntegrationTest {
|
|||||||
|
|
||||||
savedTheorem.setBranch("Test Update");
|
savedTheorem.setBranch("Test Update");
|
||||||
|
|
||||||
final TheoremDto updatedTheorem = theoremRepository.save(savedTheorem);
|
final Theorem updatedTheorem = theoremRepository.save(savedTheorem);
|
||||||
|
|
||||||
assertNotNull(updatedTheorem);
|
assertNotNull(updatedTheorem);
|
||||||
assertEquals(Integer.valueOf(0), updatedTheorem.getVersion());
|
assertEquals(Integer.valueOf(0), updatedTheorem.getVersion());
|
||||||
@@ -57,12 +57,12 @@ public class TheoremsIntegrationTest {
|
|||||||
assertEquals("test definition 2", updatedTheorem.getReferencedDefinitions().get(1));
|
assertEquals("test definition 2", updatedTheorem.getReferencedDefinitions().get(1));
|
||||||
assertEquals(updatedTheorem.getId(), id);
|
assertEquals(updatedTheorem.getId(), id);
|
||||||
|
|
||||||
theoremRepository.delete(theoremDto);
|
theoremRepository.delete(theorem);
|
||||||
final Optional<TheoremDto> deletedTheorem = theoremRepository.findById(id);
|
final Optional<Theorem> deletedTheorem = theoremRepository.findById(id);
|
||||||
assertFalse(deletedTheorem.isPresent());
|
assertFalse(deletedTheorem.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private TheoremDto createTheorem() {
|
private Theorem createTheorem() {
|
||||||
final List<String> referencedTheoremsList = new ArrayList<>();
|
final List<String> referencedTheoremsList = new ArrayList<>();
|
||||||
referencedTheoremsList.add("test theorem 1");
|
referencedTheoremsList.add("test theorem 1");
|
||||||
referencedTheoremsList.add("test theorem 2");
|
referencedTheoremsList.add("test theorem 2");
|
||||||
@@ -71,14 +71,14 @@ public class TheoremsIntegrationTest {
|
|||||||
referencedDefinitionsList.add("test definition 1");
|
referencedDefinitionsList.add("test definition 1");
|
||||||
referencedDefinitionsList.add("test definition 2");
|
referencedDefinitionsList.add("test definition 2");
|
||||||
|
|
||||||
final TheoremDto theoremDto = new TheoremDto();
|
final Theorem theorem = new Theorem();
|
||||||
theoremDto.setName("Test theorem");
|
theorem.setName("Test theorem");
|
||||||
theoremDto.setBranch("Test branch");
|
theorem.setBranch("Test branch");
|
||||||
theoremDto.setProvenStatus(true);
|
theorem.setProvenStatus(true);
|
||||||
theoremDto.setTheoremType(TheoremType.THEOREM);
|
theorem.setTheoremType(TheoremType.THEOREM);
|
||||||
theoremDto.setReferencedTheorems(referencedTheoremsList);
|
theorem.setReferencedTheorems(referencedTheoremsList);
|
||||||
theoremDto.setReferencedDefinitions(referencedDefinitionsList);
|
theorem.setReferencedDefinitions(referencedDefinitionsList);
|
||||||
|
|
||||||
return theoremDto;
|
return theorem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-21
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.AccountDto;
|
import edu.msudenver.tsp.persistence.dto.Account;
|
||||||
import edu.msudenver.tsp.persistence.repository.AccountsRepository;
|
import edu.msudenver.tsp.persistence.repository.AccountsRepository;
|
||||||
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -28,7 +28,7 @@ public class AccountController {
|
|||||||
|
|
||||||
@GetMapping({"","/"})
|
@GetMapping({"","/"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<Iterable<AccountDto>> getListOfAccounts() {
|
ResponseEntity<Iterable<Account>> getListOfAccounts() {
|
||||||
LOG.info("Received request to list all accounts");
|
LOG.info("Received request to list all accounts");
|
||||||
|
|
||||||
LOG.debug("Querying for list of accounts");
|
LOG.debug("Querying for list of accounts");
|
||||||
@@ -36,7 +36,7 @@ public class AccountController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<AccountDto> listOfAccounts = (List<AccountDto>) accountsRepository.findAll();
|
final List<Account> listOfAccounts = (List<Account>) accountsRepository.findAll();
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ public class AccountController {
|
|||||||
|
|
||||||
@GetMapping("/id")
|
@GetMapping("/id")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<AccountDto> getAccountById(@RequestParam("id") final Integer id) {
|
ResponseEntity<Account> getAccountById(@RequestParam("id") final Integer id) {
|
||||||
LOG.info("Received request to query for account with id {}", id);
|
LOG.info("Received request to query for account with id {}", id);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
LOG.error("ERROR: ID was null");
|
LOG.error("ERROR: ID was null");
|
||||||
@@ -59,7 +59,7 @@ public class AccountController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<AccountDto> account = accountsRepository.findById(id);
|
final Optional<Account> account = accountsRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ public class AccountController {
|
|||||||
|
|
||||||
@GetMapping("/username")
|
@GetMapping("/username")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<AccountDto> getAccountByUsername(@RequestParam("username") final String username) {
|
ResponseEntity<Account> getAccountByUsername(@RequestParam("username") final String username) {
|
||||||
LOG.info("Received request to query for account with username {}", username);
|
LOG.info("Received request to query for account with username {}", username);
|
||||||
if (username == null) {
|
if (username == null) {
|
||||||
LOG.error("ERROR: username was null");
|
LOG.error("ERROR: username was null");
|
||||||
@@ -88,7 +88,7 @@ public class AccountController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<AccountDto> account = accountsRepository.findByUsername(username);
|
final Optional<Account> account = accountsRepository.findByUsername(username);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -105,9 +105,9 @@ public class AccountController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"","/"})
|
@PostMapping({"","/"})
|
||||||
@Validated({AccountDto.Insert.class, Default.class})
|
@Validated({Account.Insert.class, Default.class})
|
||||||
public @ResponseBody ResponseEntity<AccountDto> insertAccount(
|
public @ResponseBody ResponseEntity<Account> insertAccount(
|
||||||
@Valid @RequestBody final AccountDto accountDto, final BindingResult bindingResult) {
|
@Valid @RequestBody final Account account, final BindingResult bindingResult) {
|
||||||
|
|
||||||
LOG.info("Received request to insert a new account");
|
LOG.info("Received request to insert a new account");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -115,23 +115,23 @@ public class AccountController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accountDto == null) {
|
if (account == null) {
|
||||||
LOG.error("Passed account is unprocessable");
|
LOG.error("Passed account is unprocessable");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Checking for any existing users with username {}", accountDto.getUsername());
|
LOG.info("Checking for any existing users with username {}", account.getUsername());
|
||||||
|
|
||||||
final Instant start = Instant.now();
|
final Instant start = Instant.now();
|
||||||
|
|
||||||
LOG.debug("Querying for existing accounts");
|
LOG.debug("Querying for existing accounts");
|
||||||
|
|
||||||
final Optional<AccountDto> existingAccount = accountsRepository.findByUsername(accountDto.getUsername());
|
final Optional<Account> existingAccount = accountsRepository.findByUsername(account.getUsername());
|
||||||
|
|
||||||
LOG.debug("Received response from the server: query took {} ms", Duration.between(start, Instant.now()).toMillis());
|
LOG.debug("Received response from the server: query took {} ms", Duration.between(start, Instant.now()).toMillis());
|
||||||
|
|
||||||
if (existingAccount.isPresent()) {
|
if (existingAccount.isPresent()) {
|
||||||
LOG.warn("An account already exists with username {}", accountDto.getUsername());
|
LOG.warn("An account already exists with username {}", account.getUsername());
|
||||||
return new ResponseEntity<>(HttpStatus.CONFLICT);
|
return new ResponseEntity<>(HttpStatus.CONFLICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ public class AccountController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final AccountDto savedAccount = accountsRepository.save(accountDto);
|
final Account savedAccount = accountsRepository.save(account);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -150,9 +150,9 @@ public class AccountController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
public @ResponseBody ResponseEntity<AccountDto> updateAccount(
|
public @ResponseBody ResponseEntity<Account> updateAccount(
|
||||||
@PathVariable("id") final Integer id,
|
@PathVariable("id") final Integer id,
|
||||||
@RequestBody final AccountDto accountDto, final BindingResult bindingResult) {
|
@RequestBody final Account account, final BindingResult bindingResult) {
|
||||||
|
|
||||||
LOG.info("Received request to update an account");
|
LOG.info("Received request to update an account");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -160,7 +160,7 @@ public class AccountController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accountDto == null) {
|
if (account == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ public class AccountController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<AccountDto> existingAccount = accountsRepository.findById(id);
|
final Optional<Account> existingAccount = accountsRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ public class AccountController {
|
|||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistenceUtilities.copyNonNullProperties(accountDto, existingAccount.get());
|
PersistenceUtilities.copyNonNullProperties(account, existingAccount.get());
|
||||||
existingAccount.get().setVersion(existingAccount.get().getVersion()+ 1);
|
existingAccount.get().setVersion(existingAccount.get().getVersion()+ 1);
|
||||||
|
|
||||||
LOG.info("Updating account with id {}", id);
|
LOG.info("Updating account with id {}", id);
|
||||||
@@ -194,7 +194,7 @@ public class AccountController {
|
|||||||
|
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final AccountDto updatedAccount = accountsRepository.save(existingAccount.get());
|
final Account updatedAccount = accountsRepository.save(existingAccount.get());
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.DefinitionDto;
|
import edu.msudenver.tsp.persistence.dto.Definition;
|
||||||
import edu.msudenver.tsp.persistence.repository.DefinitionRepository;
|
import edu.msudenver.tsp.persistence.repository.DefinitionRepository;
|
||||||
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -26,14 +26,14 @@ public class DefinitionController {
|
|||||||
|
|
||||||
@GetMapping({"","/"})
|
@GetMapping({"","/"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<Iterable<DefinitionDto>> getAllDefinitions() {
|
ResponseEntity<Iterable<Definition>> getAllDefinitions() {
|
||||||
LOG.info("Received request to list all definitions");
|
LOG.info("Received request to list all definitions");
|
||||||
|
|
||||||
LOG.debug("Querying for list of all definitions");
|
LOG.debug("Querying for list of all definitions");
|
||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<DefinitionDto> listOfDefinitions = definitionRepository.findAll();
|
final List<Definition> listOfDefinitions = definitionRepository.findAll();
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class DefinitionController {
|
|||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<DefinitionDto> getDefinitionById(@PathVariable("id") final Integer id) {
|
ResponseEntity<Definition> getDefinitionById(@PathVariable("id") final Integer id) {
|
||||||
LOG.info("Received request to query for definition with id {}", id);
|
LOG.info("Received request to query for definition with id {}", id);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
LOG.error("ERROR: ID was null");
|
LOG.error("ERROR: ID was null");
|
||||||
@@ -57,7 +57,7 @@ public class DefinitionController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<DefinitionDto> definition = definitionRepository.findById(id);
|
final Optional<Definition> definition = definitionRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -74,9 +74,9 @@ public class DefinitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"","/"})
|
@PostMapping({"","/"})
|
||||||
@Validated({DefinitionDto.Insert.class, Default.class})
|
@Validated({Definition.Insert.class, Default.class})
|
||||||
public @ResponseBody ResponseEntity<DefinitionDto> insertDefinition(
|
public @ResponseBody ResponseEntity<Definition> insertDefinition(
|
||||||
@Valid @RequestBody final DefinitionDto definitionDto,
|
@Valid @RequestBody final Definition definition,
|
||||||
final BindingResult bindingResult) {
|
final BindingResult bindingResult) {
|
||||||
LOG.info("Received request to insert a new definition");
|
LOG.info("Received request to insert a new definition");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -84,7 +84,7 @@ public class DefinitionController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (definitionDto == null) {
|
if (definition == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ public class DefinitionController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final DefinitionDto savedDefinition = definitionRepository.save(definitionDto);
|
final Definition savedDefinition = definitionRepository.save(definition);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||||
@@ -104,9 +104,9 @@ public class DefinitionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
public @ResponseBody ResponseEntity<DefinitionDto> updateDefinition(
|
public @ResponseBody ResponseEntity<Definition> updateDefinition(
|
||||||
@PathVariable("id") final Integer id,
|
@PathVariable("id") final Integer id,
|
||||||
@RequestBody final DefinitionDto definitionDto, final BindingResult bindingResult) {
|
@RequestBody final Definition definition, final BindingResult bindingResult) {
|
||||||
|
|
||||||
LOG.info("Received request to update an account");
|
LOG.info("Received request to update an account");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -114,7 +114,7 @@ public class DefinitionController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (definitionDto == null) {
|
if (definition == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ public class DefinitionController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<DefinitionDto> existingDefinition = definitionRepository.findById(id);
|
final Optional<Definition> existingDefinition = definitionRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ public class DefinitionController {
|
|||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistenceUtilities.copyNonNullProperties(definitionDto, existingDefinition.get());
|
PersistenceUtilities.copyNonNullProperties(definition, existingDefinition.get());
|
||||||
existingDefinition.get().setVersion(existingDefinition.get().getVersion()+ 1);
|
existingDefinition.get().setVersion(existingDefinition.get().getVersion()+ 1);
|
||||||
|
|
||||||
LOG.info("Updating definition with id {}", id);
|
LOG.info("Updating definition with id {}", id);
|
||||||
@@ -148,7 +148,7 @@ public class DefinitionController {
|
|||||||
|
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final DefinitionDto updatedDefinition = definitionRepository.save(existingDefinition.get());
|
final Definition updatedDefinition = definitionRepository.save(existingDefinition.get());
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
|
|||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.repository.NotationRepository;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class NotationController {
|
|
||||||
private final NotationRepository notationRepository;
|
|
||||||
}
|
|
||||||
+20
-20
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.ProofDto;
|
import edu.msudenver.tsp.persistence.dto.Proof;
|
||||||
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
||||||
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -26,14 +26,14 @@ public class ProofController {
|
|||||||
|
|
||||||
@GetMapping({"","/"})
|
@GetMapping({"","/"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<Iterable<ProofDto>> getAllProofs() {
|
ResponseEntity<Iterable<Proof>> getAllProofs() {
|
||||||
LOG.info("Received request to list all theorems");
|
LOG.info("Received request to list all theorems");
|
||||||
|
|
||||||
LOG.debug("Querying for list of all theorems");
|
LOG.debug("Querying for list of all theorems");
|
||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<ProofDto> listOfProofs = proofRepository.findAll();
|
final List<Proof> listOfProofs = proofRepository.findAll();
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class ProofController {
|
|||||||
|
|
||||||
@GetMapping("/id")
|
@GetMapping("/id")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ProofDto> getProofById(@RequestParam("id") final Integer id) {
|
ResponseEntity<Proof> getProofById(@RequestParam("id") final Integer id) {
|
||||||
LOG.info("Received request to query for proof with id {}", id);
|
LOG.info("Received request to query for proof with id {}", id);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
LOG.error("ERROR: ID was null");
|
LOG.error("ERROR: ID was null");
|
||||||
@@ -57,7 +57,7 @@ public class ProofController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<ProofDto> proof = proofRepository.findById(id);
|
final Optional<Proof> proof = proofRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ public class ProofController {
|
|||||||
|
|
||||||
@GetMapping("/branch")
|
@GetMapping("/branch")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<List<ProofDto>> getAllProofsByBranch(@RequestParam("branch") final String branch) {
|
ResponseEntity<List<Proof>> getAllProofsByBranch(@RequestParam("branch") final String branch) {
|
||||||
LOG.info("Received request to query for proofs related to the {} branch of mathematics", branch);
|
LOG.info("Received request to query for proofs related to the {} branch of mathematics", branch);
|
||||||
if (branch == null) {
|
if (branch == null) {
|
||||||
LOG.error("ERROR: branch was null");
|
LOG.error("ERROR: branch was null");
|
||||||
@@ -87,7 +87,7 @@ public class ProofController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<ProofDto> listOfProofs = proofRepository.findByBranch(branch);
|
final List<Proof> listOfProofs = proofRepository.findByBranch(branch);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ public class ProofController {
|
|||||||
|
|
||||||
@GetMapping("/theorem_name")
|
@GetMapping("/theorem_name")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<List<ProofDto>> getAllProofsByTheoremName(@PathVariable("theorem_name") final String theoremName) {
|
ResponseEntity<List<Proof>> getAllProofsByTheoremName(@PathVariable("theorem_name") final String theoremName) {
|
||||||
LOG.info("Received request to query for proofs of the theorem {}", theoremName);
|
LOG.info("Received request to query for proofs of the theorem {}", theoremName);
|
||||||
if (theoremName == null) {
|
if (theoremName == null) {
|
||||||
LOG.error("ERROR: theorem name was null");
|
LOG.error("ERROR: theorem name was null");
|
||||||
@@ -117,7 +117,7 @@ public class ProofController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<ProofDto> listOfProofs = proofRepository.findByTheoremName(theoremName);
|
final List<Proof> listOfProofs = proofRepository.findByTheoremName(theoremName);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ public class ProofController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"","/"})
|
@PostMapping({"","/"})
|
||||||
@Validated({ProofDto.Insert.class, Default.class})
|
@Validated({Proof.Insert.class, Default.class})
|
||||||
public @ResponseBody ResponseEntity<ProofDto> insertProof(
|
public @ResponseBody ResponseEntity<Proof> insertProof(
|
||||||
@Valid @RequestBody final ProofDto proofDto,
|
@Valid @RequestBody final Proof proof,
|
||||||
final BindingResult bindingResult) {
|
final BindingResult bindingResult) {
|
||||||
LOG.info("Received request to insert a new proof");
|
LOG.info("Received request to insert a new proof");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -144,7 +144,7 @@ public class ProofController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proofDto == null) {
|
if (proof == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ public class ProofController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final ProofDto savedProof = proofRepository.save(proofDto);
|
final Proof savedProof = proofRepository.save(proof);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||||
@@ -164,9 +164,9 @@ public class ProofController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
public @ResponseBody ResponseEntity<ProofDto> updateProof(
|
public @ResponseBody ResponseEntity<Proof> updateProof(
|
||||||
@PathVariable("id") final Integer id,
|
@PathVariable("id") final Integer id,
|
||||||
@RequestBody final ProofDto proofDto, final BindingResult bindingResult) {
|
@RequestBody final Proof proof, final BindingResult bindingResult) {
|
||||||
|
|
||||||
LOG.info("Received request to update a proof");
|
LOG.info("Received request to update a proof");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -174,7 +174,7 @@ public class ProofController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proofDto == null) {
|
if (proof == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ public class ProofController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<ProofDto> existingProof = proofRepository.findById(id);
|
final Optional<Proof> existingProof = proofRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class ProofController {
|
|||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistenceUtilities.copyNonNullProperties(proofDto, existingProof.get());
|
PersistenceUtilities.copyNonNullProperties(proof, existingProof.get());
|
||||||
existingProof.get().setVersion(existingProof.get().getVersion()+ 1);
|
existingProof.get().setVersion(existingProof.get().getVersion()+ 1);
|
||||||
|
|
||||||
LOG.info("Updating proof with id {}", id);
|
LOG.info("Updating proof with id {}", id);
|
||||||
@@ -208,7 +208,7 @@ public class ProofController {
|
|||||||
|
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final ProofDto updatedProof = proofRepository.save(existingProof.get());
|
final Proof updatedProof = proofRepository.save(existingProof.get());
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
|
|||||||
+22
-22
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.TheoremDto;
|
import edu.msudenver.tsp.persistence.dto.Theorem;
|
||||||
import edu.msudenver.tsp.persistence.repository.TheoremRepository;
|
import edu.msudenver.tsp.persistence.repository.TheoremRepository;
|
||||||
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -26,14 +26,14 @@ public class TheoremController {
|
|||||||
|
|
||||||
@GetMapping({"","/"})
|
@GetMapping({"","/"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<Iterable<TheoremDto>> getAllTheorems() {
|
ResponseEntity<Iterable<Theorem>> getAllTheorems() {
|
||||||
LOG.info("Received request to list all theorems");
|
LOG.info("Received request to list all theorems");
|
||||||
|
|
||||||
LOG.debug("Querying for list of all theorems");
|
LOG.debug("Querying for list of all theorems");
|
||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<TheoremDto> listOfTheorems = theoremRepository.findAll();
|
final List<Theorem> listOfTheorems = theoremRepository.findAll();
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class TheoremController {
|
|||||||
|
|
||||||
@GetMapping("/branch")
|
@GetMapping("/branch")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<List<TheoremDto>> getAllTheoremsByBranch(@RequestParam("branch") final String branch) {
|
ResponseEntity<List<Theorem>> getAllTheoremsByBranch(@RequestParam("branch") final String branch) {
|
||||||
LOG.info("Received request to query for theorems related to the {} branch of mathematics", branch);
|
LOG.info("Received request to query for theorems related to the {} branch of mathematics", branch);
|
||||||
if (branch == null) {
|
if (branch == null) {
|
||||||
LOG.error("ERROR: branch was null");
|
LOG.error("ERROR: branch was null");
|
||||||
@@ -57,7 +57,7 @@ public class TheoremController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<TheoremDto> listOfTheorems = theoremRepository.findByBranch(branch);
|
final List<Theorem> listOfTheorems = theoremRepository.findByBranch(branch);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ public class TheoremController {
|
|||||||
|
|
||||||
@GetMapping("/proven_status")
|
@GetMapping("/proven_status")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<List<TheoremDto>> getAllTheoremsByProvenStatus(@PathVariable("proven_status") final Boolean provenStatus) {
|
ResponseEntity<List<Theorem>> getAllTheoremsByProvenStatus(@PathVariable("proven_status") final Boolean provenStatus) {
|
||||||
LOG.info("Received request to query for theorems whose proven status is {}", provenStatus);
|
LOG.info("Received request to query for theorems whose proven status is {}", provenStatus);
|
||||||
if (provenStatus == null) {
|
if (provenStatus == null) {
|
||||||
LOG.error("ERROR: status was null");
|
LOG.error("ERROR: status was null");
|
||||||
@@ -87,7 +87,7 @@ public class TheoremController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<TheoremDto> listOfTheorems = theoremRepository.findByProvenStatus(provenStatus);
|
final List<Theorem> listOfTheorems = theoremRepository.findByProvenStatus(provenStatus);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ public class TheoremController {
|
|||||||
|
|
||||||
@GetMapping("/name")
|
@GetMapping("/name")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<List<TheoremDto>> getAllTheoremsByName(@PathVariable("name") final String name) {
|
ResponseEntity<List<Theorem>> getAllTheoremsByName(@PathVariable("name") final String name) {
|
||||||
LOG.info("Received request to query for theorems whose name is {}", name);
|
LOG.info("Received request to query for theorems whose name is {}", name);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
LOG.error("ERROR: name was null");
|
LOG.error("ERROR: name was null");
|
||||||
@@ -117,7 +117,7 @@ public class TheoremController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final List<TheoremDto> listOfTheorems = theoremRepository.findByName(name);
|
final List<Theorem> listOfTheorems = theoremRepository.findByName(name);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ public class TheoremController {
|
|||||||
|
|
||||||
@GetMapping("/id")
|
@GetMapping("/id")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<TheoremDto> getTheoremById(@PathVariable("id") final Integer id) {
|
ResponseEntity<Theorem> getTheoremById(@PathVariable("id") final Integer id) {
|
||||||
LOG.info("Received request to query for theorem with id {}", id);
|
LOG.info("Received request to query for theorem with id {}", id);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
LOG.error("ERROR: ID was null");
|
LOG.error("ERROR: ID was null");
|
||||||
@@ -147,7 +147,7 @@ public class TheoremController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<TheoremDto> theorem = theoremRepository.findById(id);
|
final Optional<Theorem> theorem = theoremRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -164,9 +164,9 @@ public class TheoremController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"","/"})
|
@PostMapping({"","/"})
|
||||||
@Validated({TheoremDto.Insert.class, Default.class})
|
@Validated({Theorem.Insert.class, Default.class})
|
||||||
public @ResponseBody ResponseEntity<TheoremDto> insertTheorem(
|
public @ResponseBody ResponseEntity<Theorem> insertTheorem(
|
||||||
@Valid @RequestBody final TheoremDto theoremDto,
|
@Valid @RequestBody final Theorem theorem,
|
||||||
final BindingResult bindingResult) {
|
final BindingResult bindingResult) {
|
||||||
LOG.info("Received request to insert a new theorem");
|
LOG.info("Received request to insert a new theorem");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -174,7 +174,7 @@ public class TheoremController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theoremDto == null) {
|
if (theorem == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ public class TheoremController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final TheoremDto savedTheorem = theoremRepository.save(theoremDto);
|
final Theorem savedTheorem = theoremRepository.save(theorem);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
LOG.debug("Received response from server: query took {}ms to complete", stopWatch.getTotalTimeMillis());
|
||||||
@@ -194,9 +194,9 @@ public class TheoremController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
public @ResponseBody ResponseEntity<TheoremDto> updateTheorem(
|
public @ResponseBody ResponseEntity<Theorem> updateTheorem(
|
||||||
@PathVariable("id") final Integer id,
|
@PathVariable("id") final Integer id,
|
||||||
@RequestBody final TheoremDto theoremDto, final BindingResult bindingResult) {
|
@RequestBody final Theorem theorem, final BindingResult bindingResult) {
|
||||||
|
|
||||||
LOG.info("Received request to update a theorem");
|
LOG.info("Received request to update a theorem");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
@@ -204,7 +204,7 @@ public class TheoremController {
|
|||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theoremDto == null) {
|
if (theorem == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ public class TheoremController {
|
|||||||
final StopWatch stopWatch = new StopWatch();
|
final StopWatch stopWatch = new StopWatch();
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final Optional<TheoremDto> existingTheorem = theoremRepository.findById(id);
|
final Optional<Theorem> existingTheorem = theoremRepository.findById(id);
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ public class TheoremController {
|
|||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistenceUtilities.copyNonNullProperties(theoremDto, existingTheorem.get());
|
PersistenceUtilities.copyNonNullProperties(theorem, existingTheorem.get());
|
||||||
existingTheorem.get().setVersion(existingTheorem.get().getVersion()+ 1);
|
existingTheorem.get().setVersion(existingTheorem.get().getVersion()+ 1);
|
||||||
|
|
||||||
LOG.info("Updating theorem with id {}", id);
|
LOG.info("Updating theorem with id {}", id);
|
||||||
@@ -238,7 +238,7 @@ public class TheoremController {
|
|||||||
|
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
|
||||||
final TheoremDto updatedTheorem = theoremRepository.save(existingTheorem.get());
|
final Theorem updatedTheorem = theoremRepository.save(existingTheorem.get());
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ import java.util.Date;
|
|||||||
@EntityListeners(AuditingEntityListener.class)
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class AccountDto extends BaseDto implements Serializable {
|
public class Account extends BaseDto implements Serializable {
|
||||||
@NotBlank(groups = Insert.class, message = "A username must be specified") @Size(max = 50) private String username;
|
@NotBlank(groups = Insert.class, message = "A username must be specified") @Size(max = 50) private String username;
|
||||||
@NotBlank(groups = Insert.class, message = "A password must be specified") @Size(max = 256) private String password;
|
@NotBlank(groups = Insert.class, message = "A password must be specified") @Size(max = 256) private String password;
|
||||||
@NotNull @Column(name = "administrator_status") private boolean administratorStatus;
|
@NotNull @Column(name = "administrator_status") private boolean administratorStatus;
|
||||||
+1
-1
@@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
@EntityListeners(AuditingEntityListener.class)
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class DefinitionDto extends BaseDto implements Serializable {
|
public class Definition extends BaseDto implements Serializable {
|
||||||
@NotBlank(groups = Insert.class, message = "A name must be specified")
|
@NotBlank(groups = Insert.class, message = "A name must be specified")
|
||||||
@Size(min = 1, max = 200, message = "Must be between 1 and 200 characters")
|
@Size(min = 1, max = 200, message = "Must be between 1 and 200 characters")
|
||||||
private String name;
|
private String name;
|
||||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
@EntityListeners(AuditingEntityListener.class)
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class ProofDto extends BaseDto implements Serializable {
|
public class Proof extends BaseDto implements Serializable {
|
||||||
@NotBlank(groups = Insert.class)
|
@NotBlank(groups = Insert.class)
|
||||||
@Size(min = 1, max = 512, message = "The name must be at least 1 character and at most 512 characters")
|
@Size(min = 1, max = 512, message = "The name must be at least 1 character and at most 512 characters")
|
||||||
@Column(name = "theorem_name")
|
@Column(name = "theorem_name")
|
||||||
+1
-1
@@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
@EntityListeners(AuditingEntityListener.class)
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class TheoremDto extends BaseDto implements Serializable {
|
public class Theorem extends BaseDto implements Serializable {
|
||||||
@NotBlank(groups = Insert.class) @Size(min = 1, max = 512, message = "theorem name must be between 1 and 512 characters") private String name;
|
@NotBlank(groups = Insert.class) @Size(min = 1, max = 512, message = "theorem name must be between 1 and 512 characters") private String name;
|
||||||
@NotNull(groups = Insert.class) @Column(name = "theorem_type") private TheoremType theoremType;
|
@NotNull(groups = Insert.class) @Column(name = "theorem_type") private TheoremType theoremType;
|
||||||
@NotNull(groups = Insert.class, message = "a branch of mathematics that this theorem is associated with must be specified") private String branch;
|
@NotNull(groups = Insert.class, message = "a branch of mathematics that this theorem is associated with must be specified") private String branch;
|
||||||
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
package edu.msudenver.tsp.persistence.repository;
|
package edu.msudenver.tsp.persistence.repository;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.AccountDto;
|
import edu.msudenver.tsp.persistence.dto.Account;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface AccountsRepository extends CrudRepository<AccountDto, Integer> {
|
public interface AccountsRepository extends CrudRepository<Account, Integer> {
|
||||||
Optional<AccountDto> findByUsername(String username);
|
Optional<Account> findByUsername(String username);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
package edu.msudenver.tsp.persistence.repository;
|
package edu.msudenver.tsp.persistence.repository;
|
||||||
|
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.DefinitionDto;
|
import edu.msudenver.tsp.persistence.dto.Definition;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface DefinitionRepository extends JpaRepository<DefinitionDto, Integer> {
|
public interface DefinitionRepository extends JpaRepository<Definition, Integer> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
package edu.msudenver.tsp.persistence.repository;
|
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.BaseDto;
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
|
|
||||||
public interface NotationRepository extends CrudRepository<BaseDto, Long> {
|
|
||||||
}
|
|
||||||
+4
-4
@@ -1,13 +1,13 @@
|
|||||||
package edu.msudenver.tsp.persistence.repository;
|
package edu.msudenver.tsp.persistence.repository;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.ProofDto;
|
import edu.msudenver.tsp.persistence.dto.Proof;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ProofRepository extends JpaRepository<ProofDto, Integer> {
|
public interface ProofRepository extends JpaRepository<Proof, Integer> {
|
||||||
|
|
||||||
List<ProofDto> findByBranch(String branch);
|
List<Proof> findByBranch(String branch);
|
||||||
|
|
||||||
List<ProofDto> findByTheoremName(String name);
|
List<Proof> findByTheoremName(String name);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -1,17 +1,17 @@
|
|||||||
package edu.msudenver.tsp.persistence.repository;
|
package edu.msudenver.tsp.persistence.repository;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.TheoremDto;
|
import edu.msudenver.tsp.persistence.dto.Theorem;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface TheoremRepository extends JpaRepository<TheoremDto, Integer> {
|
public interface TheoremRepository extends JpaRepository<Theorem, Integer> {
|
||||||
|
|
||||||
List<TheoremDto> findByBranch(String branch);
|
List<Theorem> findByBranch(String branch);
|
||||||
|
|
||||||
List<TheoremDto> findByProvenStatus(Boolean provenStatus);
|
List<Theorem> findByProvenStatus(Boolean provenStatus);
|
||||||
|
|
||||||
List<TheoremDto> findByName(String name);
|
List<Theorem> findByName(String name);
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-43
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.AccountDto;
|
import edu.msudenver.tsp.persistence.dto.Account;
|
||||||
import edu.msudenver.tsp.persistence.repository.AccountsRepository;
|
import edu.msudenver.tsp.persistence.repository.AccountsRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -33,14 +33,14 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllAccounts() {
|
public void testGetAllAccounts() {
|
||||||
final AccountDto accountDto = createAccount();
|
final Account accountDto = createAccount();
|
||||||
final List<AccountDto> accountDtoList = new ArrayList<>();
|
final List<Account> accountList = new ArrayList<>();
|
||||||
accountDtoList.add(accountDto);
|
accountList.add(accountDto);
|
||||||
accountDtoList.add(accountDto);
|
accountList.add(accountDto);
|
||||||
|
|
||||||
when(accountsRepository.findAll()).thenReturn(accountDtoList);
|
when(accountsRepository.findAll()).thenReturn(accountList);
|
||||||
|
|
||||||
final ResponseEntity<Iterable<AccountDto>> responseEntity = accountController.getListOfAccounts();
|
final ResponseEntity<Iterable<Account>> responseEntity = accountController.getListOfAccounts();
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -52,16 +52,16 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAccountById() {
|
public void testGetAccountById() {
|
||||||
final AccountDto accountDto = createAccount();
|
final Account account = createAccount();
|
||||||
when(accountsRepository.findById(anyInt())).thenReturn(Optional.ofNullable(accountDto));
|
when(accountsRepository.findById(anyInt())).thenReturn(Optional.ofNullable(account));
|
||||||
|
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.getAccountById(1);
|
final ResponseEntity<Account> responseEntity = accountController.getAccountById(1);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(accountDto, responseEntity.getBody());
|
assertEquals(account, responseEntity.getBody());
|
||||||
verify(accountsRepository).findById(anyInt());
|
verify(accountsRepository).findById(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,16 +89,16 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAccountByUsername() {
|
public void testGetAccountByUsername() {
|
||||||
final AccountDto accountDto = createAccount();
|
final Account account = createAccount();
|
||||||
when(accountsRepository.findByUsername(anyString())).thenReturn(Optional.ofNullable(accountDto));
|
when(accountsRepository.findByUsername(anyString())).thenReturn(Optional.ofNullable(account));
|
||||||
|
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.getAccountByUsername("Test username");
|
final ResponseEntity<Account> responseEntity = accountController.getAccountByUsername("Test username");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(accountDto, responseEntity.getBody());
|
assertEquals(account, responseEntity.getBody());
|
||||||
verify(accountsRepository).findByUsername(anyString());
|
verify(accountsRepository).findByUsername(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,32 +126,32 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertAccount() {
|
public void testInsertAccount() {
|
||||||
final AccountDto accountDto = createAccount();
|
final Account account = createAccount();
|
||||||
when(accountsRepository.save(any(AccountDto.class))).thenReturn(accountDto);
|
when(accountsRepository.save(any(Account.class))).thenReturn(account);
|
||||||
when(accountsRepository.findByUsername(anyString())).thenReturn(Optional.empty());
|
when(accountsRepository.findByUsername(anyString())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.insertAccount(accountDto, bindingResult);
|
final ResponseEntity<Account> responseEntity = accountController.insertAccount(account, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
||||||
assertEquals(accountDto, responseEntity.getBody());
|
assertEquals(account, responseEntity.getBody());
|
||||||
verify(accountsRepository).save(any(AccountDto.class));
|
verify(accountsRepository).save(any(Account.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertAccount_usernameAlreadyExists() {
|
public void testInsertAccount_usernameAlreadyExists() {
|
||||||
final AccountDto accountDto = createAccount();
|
final Account account = createAccount();
|
||||||
when(accountsRepository.findByUsername(anyString())).thenReturn(Optional.of(accountDto));
|
when(accountsRepository.findByUsername(anyString())).thenReturn(Optional.of(account));
|
||||||
|
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.insertAccount(accountDto, bindingResult);
|
final ResponseEntity<Account> responseEntity = accountController.insertAccount(account, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.CONFLICT, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.CONFLICT, responseEntity.getStatusCode());
|
||||||
verify(accountsRepository).findByUsername(anyString());
|
verify(accountsRepository).findByUsername(anyString());
|
||||||
verify(accountsRepository, times(0)).save(any(AccountDto.class));
|
verify(accountsRepository, times(0)).save(any(Account.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -166,10 +166,10 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertAccount_bindingResultHasErrors() {
|
public void testInsertAccount_bindingResultHasErrors() {
|
||||||
final AccountDto accountDto = createAccount();
|
final Account account = createAccount();
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity responseEntity = accountController.insertAccount(accountDto, bindingResult);
|
final ResponseEntity responseEntity = accountController.insertAccount(account, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -179,31 +179,31 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateAccount() {
|
public void testUpdateAccount() {
|
||||||
final AccountDto existingAccount = createAccount();
|
final Account existingAccount = createAccount();
|
||||||
existingAccount.setId(1);
|
existingAccount.setId(1);
|
||||||
existingAccount.setVersion(1);
|
existingAccount.setVersion(1);
|
||||||
final AccountDto accountUpdate = new AccountDto();
|
final Account accountUpdate = new Account();
|
||||||
accountUpdate.setUsername("Test Update");
|
accountUpdate.setUsername("Test Update");
|
||||||
final AccountDto updatedAccount = existingAccount;
|
final Account updatedAccount = existingAccount;
|
||||||
updatedAccount.setUsername("Test Update");
|
updatedAccount.setUsername("Test Update");
|
||||||
when(accountsRepository.findById(anyInt())).thenReturn(Optional.of(existingAccount));
|
when(accountsRepository.findById(anyInt())).thenReturn(Optional.of(existingAccount));
|
||||||
when(accountsRepository.save(any(AccountDto.class))).thenReturn(updatedAccount);
|
when(accountsRepository.save(any(Account.class))).thenReturn(updatedAccount);
|
||||||
|
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.updateAccount(1, accountUpdate, bindingResult);
|
final ResponseEntity<Account> responseEntity = accountController.updateAccount(1, accountUpdate, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(updatedAccount, responseEntity.getBody());
|
assertEquals(updatedAccount, responseEntity.getBody());
|
||||||
verify(accountsRepository).findById(anyInt());
|
verify(accountsRepository).findById(anyInt());
|
||||||
verify(accountsRepository).save(any(AccountDto.class));
|
verify(accountsRepository).save(any(Account.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateAccount_bindingResultHasErrors() {
|
public void testUpdateAccount_bindingResultHasErrors() {
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.updateAccount(1, createAccount(), bindingResult);
|
final ResponseEntity<Account> responseEntity = accountController.updateAccount(1, createAccount(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -213,7 +213,7 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateAccount_accountsDtoIsNull() {
|
public void testUpdateAccount_accountsDtoIsNull() {
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.updateAccount(1, null, bindingResult);
|
final ResponseEntity<Account> responseEntity = accountController.updateAccount(1, null, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -223,7 +223,7 @@ public class AccountControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateAccount_idIsNull() {
|
public void testUpdateAccount_idIsNull() {
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.updateAccount(null, createAccount(), bindingResult);
|
final ResponseEntity<Account> responseEntity = accountController.updateAccount(null, createAccount(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -235,12 +235,12 @@ public class AccountControllerTest {
|
|||||||
public void testUpdateAccount_accountDoesNotExist() {
|
public void testUpdateAccount_accountDoesNotExist() {
|
||||||
when(accountsRepository.findById(anyInt())).thenReturn(Optional.empty());
|
when(accountsRepository.findById(anyInt())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
final ResponseEntity<AccountDto> responseEntity = accountController.updateAccount(1, createAccount(), bindingResult);
|
final ResponseEntity<Account> responseEntity = accountController.updateAccount(1, createAccount(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
||||||
verify(accountsRepository, times(0)).save(any(AccountDto.class));
|
verify(accountsRepository, times(0)).save(any(Account.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -265,12 +265,12 @@ public class AccountControllerTest {
|
|||||||
verifyZeroInteractions(accountsRepository);
|
verifyZeroInteractions(accountsRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccountDto createAccount() {
|
private Account createAccount() {
|
||||||
final AccountDto accountDto = new AccountDto();
|
final Account account = new Account();
|
||||||
accountDto.setUsername("Test username");
|
account.setUsername("Test username");
|
||||||
accountDto.setPassword("test password");
|
account.setPassword("test password");
|
||||||
accountDto.setAdministratorStatus(true);
|
account.setAdministratorStatus(true);
|
||||||
|
|
||||||
return accountDto;
|
return account;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+35
-35
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.DefinitionDto;
|
import edu.msudenver.tsp.persistence.dto.Definition;
|
||||||
import edu.msudenver.tsp.persistence.repository.DefinitionRepository;
|
import edu.msudenver.tsp.persistence.repository.DefinitionRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -30,14 +30,14 @@ public class DefinitionControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllDefinitions() {
|
public void testGetAllDefinitions() {
|
||||||
final DefinitionDto definitionDto = createDefinition();
|
final Definition definitionDto = createDefinition();
|
||||||
final List<DefinitionDto> definitionDtoList = new ArrayList<>();
|
final List<Definition> definitionList = new ArrayList<>();
|
||||||
definitionDtoList.add(definitionDto);
|
definitionList.add(definitionDto);
|
||||||
definitionDtoList.add(definitionDto);
|
definitionList.add(definitionDto);
|
||||||
|
|
||||||
when(definitionRepository.findAll()).thenReturn(definitionDtoList);
|
when(definitionRepository.findAll()).thenReturn(definitionList);
|
||||||
|
|
||||||
final ResponseEntity<Iterable<DefinitionDto>> responseEntity = definitionController.getAllDefinitions();
|
final ResponseEntity<Iterable<Definition>> responseEntity = definitionController.getAllDefinitions();
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -49,16 +49,16 @@ public class DefinitionControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDefinitionsById() {
|
public void testGetDefinitionsById() {
|
||||||
final DefinitionDto definitionDto = createDefinition();
|
final Definition definition = createDefinition();
|
||||||
when(definitionRepository.findById(anyInt())).thenReturn(Optional.ofNullable(definitionDto));
|
when(definitionRepository.findById(anyInt())).thenReturn(Optional.ofNullable(definition));
|
||||||
|
|
||||||
final ResponseEntity<DefinitionDto> responseEntity = definitionController.getDefinitionById(1);
|
final ResponseEntity<Definition> responseEntity = definitionController.getDefinitionById(1);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(definitionDto, responseEntity.getBody());
|
assertEquals(definition, responseEntity.getBody());
|
||||||
verify(definitionRepository).findById(anyInt());
|
verify(definitionRepository).findById(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,17 +86,17 @@ public class DefinitionControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertDefinition() {
|
public void testInsertDefinition() {
|
||||||
final DefinitionDto definitionDto = createDefinition();
|
final Definition definition = createDefinition();
|
||||||
when(definitionRepository.save(any(DefinitionDto.class))).thenReturn(definitionDto);
|
when(definitionRepository.save(any(Definition.class))).thenReturn(definition);
|
||||||
|
|
||||||
final ResponseEntity<DefinitionDto> responseEntity = definitionController.insertDefinition(definitionDto, bindingResult);
|
final ResponseEntity<Definition> responseEntity = definitionController.insertDefinition(definition, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
||||||
assertEquals(definitionDto, responseEntity.getBody());
|
assertEquals(definition, responseEntity.getBody());
|
||||||
verify(definitionRepository).save(any(DefinitionDto.class));
|
verify(definitionRepository).save(any(Definition.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -111,10 +111,10 @@ public class DefinitionControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertDefinition_bindingResultHasErrors() {
|
public void testInsertDefinition_bindingResultHasErrors() {
|
||||||
final DefinitionDto definitionDto = createDefinition();
|
final Definition definition = createDefinition();
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity responseEntity = definitionController.insertDefinition(definitionDto, bindingResult);
|
final ResponseEntity responseEntity = definitionController.insertDefinition(definition, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -124,31 +124,31 @@ public class DefinitionControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDefinition() {
|
public void testUpdateDefinition() {
|
||||||
final DefinitionDto existingDefinition = createDefinition();
|
final Definition existingDefinition = createDefinition();
|
||||||
existingDefinition.setId(1);
|
existingDefinition.setId(1);
|
||||||
existingDefinition.setVersion(1);
|
existingDefinition.setVersion(1);
|
||||||
final DefinitionDto definitionUpdate = new DefinitionDto();
|
final Definition definitionUpdate = new Definition();
|
||||||
definitionUpdate.setName("Test Update");
|
definitionUpdate.setName("Test Update");
|
||||||
final DefinitionDto updatedDefinition = existingDefinition;
|
final Definition updatedDefinition = existingDefinition;
|
||||||
updatedDefinition.setName("Test Update");
|
updatedDefinition.setName("Test Update");
|
||||||
when(definitionRepository.findById(anyInt())).thenReturn(Optional.of(existingDefinition));
|
when(definitionRepository.findById(anyInt())).thenReturn(Optional.of(existingDefinition));
|
||||||
when(definitionRepository.save(any(DefinitionDto.class))).thenReturn(updatedDefinition);
|
when(definitionRepository.save(any(Definition.class))).thenReturn(updatedDefinition);
|
||||||
|
|
||||||
final ResponseEntity<DefinitionDto> responseEntity = definitionController.updateDefinition(1, definitionUpdate, bindingResult);
|
final ResponseEntity<Definition> responseEntity = definitionController.updateDefinition(1, definitionUpdate, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(updatedDefinition, responseEntity.getBody());
|
assertEquals(updatedDefinition, responseEntity.getBody());
|
||||||
verify(definitionRepository).findById(anyInt());
|
verify(definitionRepository).findById(anyInt());
|
||||||
verify(definitionRepository).save(any(DefinitionDto.class));
|
verify(definitionRepository).save(any(Definition.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDefinition_bindingResultErrors() {
|
public void testUpdateDefinition_bindingResultErrors() {
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity<DefinitionDto> responseEntity = definitionController.updateDefinition(1, createDefinition(), bindingResult);
|
final ResponseEntity<Definition> responseEntity = definitionController.updateDefinition(1, createDefinition(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -158,7 +158,7 @@ public class DefinitionControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDefinition_definitionDtoIsNull() {
|
public void testUpdateDefinition_definitionDtoIsNull() {
|
||||||
final ResponseEntity<DefinitionDto> responseEntity = definitionController.updateDefinition(1, null, bindingResult);
|
final ResponseEntity<Definition> responseEntity = definitionController.updateDefinition(1, null, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -168,7 +168,7 @@ public class DefinitionControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDefinition_idIsNull() {
|
public void testUpdateDefinition_idIsNull() {
|
||||||
final ResponseEntity<DefinitionDto> responseEntity = definitionController.updateDefinition(null, createDefinition(), bindingResult);
|
final ResponseEntity<Definition> responseEntity = definitionController.updateDefinition(null, createDefinition(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -180,12 +180,12 @@ public class DefinitionControllerTest {
|
|||||||
public void testUpdateDefinition_definitionDoesntExist() {
|
public void testUpdateDefinition_definitionDoesntExist() {
|
||||||
when(definitionRepository.findById(anyInt())).thenReturn(Optional.empty());
|
when(definitionRepository.findById(anyInt())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
final ResponseEntity<DefinitionDto> responseEntity = definitionController.updateDefinition(1, createDefinition(), bindingResult);
|
final ResponseEntity<Definition> responseEntity = definitionController.updateDefinition(1, createDefinition(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
||||||
verify(definitionRepository, times(0)).save(any(DefinitionDto.class));
|
verify(definitionRepository, times(0)).save(any(Definition.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -210,18 +210,18 @@ public class DefinitionControllerTest {
|
|||||||
verifyZeroInteractions(definitionRepository);
|
verifyZeroInteractions(definitionRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefinitionDto createDefinition() {
|
private Definition createDefinition() {
|
||||||
final List<String> definitionList = new ArrayList<>();
|
final List<String> definitionList = new ArrayList<>();
|
||||||
definitionList.add("Test definition 1");
|
definitionList.add("Test definition 1");
|
||||||
|
|
||||||
final List<String> notationList = new ArrayList<>();
|
final List<String> notationList = new ArrayList<>();
|
||||||
notationList.add("\\testLaTeX");
|
notationList.add("\\testLaTeX");
|
||||||
|
|
||||||
final DefinitionDto definitionDto = new DefinitionDto();
|
final Definition definition = new Definition();
|
||||||
definitionDto.setName("Test Name");
|
definition.setName("Test Name");
|
||||||
definitionDto.setDefinition(definitionList);
|
definition.setDefinition(definitionList);
|
||||||
definitionDto.setNotation(notationList);
|
definition.setNotation(notationList);
|
||||||
|
|
||||||
return definitionDto;
|
return definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+44
-44
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.ProofDto;
|
import edu.msudenver.tsp.persistence.dto.Proof;
|
||||||
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -27,14 +27,14 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProofs() {
|
public void testGetAllProofs() {
|
||||||
final ProofDto proofDto = createProof();
|
final Proof proofDto = createProof();
|
||||||
final List<ProofDto> listOfProofs = new ArrayList<>();
|
final List<Proof> listOfProofs = new ArrayList<>();
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
|
|
||||||
when(proofRepository.findAll()).thenReturn(listOfProofs);
|
when(proofRepository.findAll()).thenReturn(listOfProofs);
|
||||||
|
|
||||||
final ResponseEntity<Iterable<ProofDto>> responseEntity = proofController.getAllProofs();
|
final ResponseEntity<Iterable<Proof>> responseEntity = proofController.getAllProofs();
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -46,14 +46,14 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProofsByBranch() {
|
public void testGetAllProofsByBranch() {
|
||||||
final ProofDto proofDto = createProof();
|
final Proof proofDto = createProof();
|
||||||
final List<ProofDto> listOfProofs = new ArrayList<>();
|
final List<Proof> listOfProofs = new ArrayList<>();
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
|
|
||||||
when(proofRepository.findByBranch(anyString())).thenReturn(listOfProofs);
|
when(proofRepository.findByBranch(anyString())).thenReturn(listOfProofs);
|
||||||
|
|
||||||
final ResponseEntity<List<ProofDto>> responseEntity = proofController.getAllProofsByBranch("test");
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByBranch("test");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -65,7 +65,7 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProfsByBranch_nullBranch() {
|
public void testGetAllProfsByBranch_nullBranch() {
|
||||||
final ResponseEntity<List<ProofDto>> responseEntity = proofController.getAllProofsByBranch(null);
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByBranch(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -77,7 +77,7 @@ public class ProofControllerTest {
|
|||||||
public void testGetAllProofsByBranch_noProofsFound() {
|
public void testGetAllProofsByBranch_noProofsFound() {
|
||||||
when(proofRepository.findByBranch(anyString())).thenReturn(Collections.emptyList());
|
when(proofRepository.findByBranch(anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
final ResponseEntity<List<ProofDto>> responseEntity = proofController.getAllProofsByBranch("test nonexistent branch");
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByBranch("test nonexistent branch");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -86,14 +86,14 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProofsByTheoremName() {
|
public void testGetAllProofsByTheoremName() {
|
||||||
final ProofDto proofDto = createProof();
|
final Proof proofDto = createProof();
|
||||||
final List<ProofDto> listOfProofs = new ArrayList<>();
|
final List<Proof> listOfProofs = new ArrayList<>();
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
|
|
||||||
when(proofRepository.findByTheoremName(anyString())).thenReturn(listOfProofs);
|
when(proofRepository.findByTheoremName(anyString())).thenReturn(listOfProofs);
|
||||||
|
|
||||||
final ResponseEntity<List<ProofDto>> responseEntity = proofController.getAllProofsByTheoremName("test");
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByTheoremName("test");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -105,7 +105,7 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProfsByTheoremName_nullTheoremName() {
|
public void testGetAllProfsByTheoremName_nullTheoremName() {
|
||||||
final ResponseEntity<List<ProofDto>> responseEntity = proofController.getAllProofsByTheoremName(null);
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByTheoremName(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -117,7 +117,7 @@ public class ProofControllerTest {
|
|||||||
public void testGetAllProofsByTheoremName_noProofsFound() {
|
public void testGetAllProofsByTheoremName_noProofsFound() {
|
||||||
when(proofRepository.findByTheoremName(anyString())).thenReturn(Collections.emptyList());
|
when(proofRepository.findByTheoremName(anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
final ResponseEntity<List<ProofDto>> responseEntity = proofController.getAllProofsByTheoremName("test nonexistent branch");
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByTheoremName("test nonexistent branch");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -126,16 +126,16 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProofById() {
|
public void testGetProofById() {
|
||||||
final ProofDto proofDto = createProof();
|
final Proof proof = createProof();
|
||||||
when(proofRepository.findById(anyInt())).thenReturn(Optional.ofNullable(proofDto));
|
when(proofRepository.findById(anyInt())).thenReturn(Optional.ofNullable(proof));
|
||||||
|
|
||||||
final ResponseEntity<ProofDto> responseEntity = proofController.getProofById(1);
|
final ResponseEntity<Proof> responseEntity = proofController.getProofById(1);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(proofDto, responseEntity.getBody());
|
assertEquals(proof, responseEntity.getBody());
|
||||||
verify(proofRepository).findById(anyInt());
|
verify(proofRepository).findById(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,17 +163,17 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertProof() {
|
public void testInsertProof() {
|
||||||
final ProofDto proofDto = createProof();
|
final Proof proof = createProof();
|
||||||
when(proofRepository.save(any(ProofDto.class))).thenReturn(proofDto);
|
when(proofRepository.save(any(Proof.class))).thenReturn(proof);
|
||||||
|
|
||||||
final ResponseEntity<ProofDto> responseEntity = proofController.insertProof(proofDto, bindingResult);
|
final ResponseEntity<Proof> responseEntity = proofController.insertProof(proof, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
||||||
assertEquals(proofDto, responseEntity.getBody());
|
assertEquals(proof, responseEntity.getBody());
|
||||||
verify(proofRepository).save(any(ProofDto.class));
|
verify(proofRepository).save(any(Proof.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -188,10 +188,10 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertProof_bindingResultHasErrors() {
|
public void testInsertProof_bindingResultHasErrors() {
|
||||||
final ProofDto proofDto = createProof();
|
final Proof proof = createProof();
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity responseEntity = proofController.insertProof(proofDto, bindingResult);
|
final ResponseEntity responseEntity = proofController.insertProof(proof, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -201,31 +201,31 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateProof() {
|
public void testUpdateProof() {
|
||||||
final ProofDto existingProof = createProof();
|
final Proof existingProof = createProof();
|
||||||
existingProof.setId(1);
|
existingProof.setId(1);
|
||||||
existingProof.setVersion(1);
|
existingProof.setVersion(1);
|
||||||
final ProofDto proofUpdate = new ProofDto();
|
final Proof proofUpdate = new Proof();
|
||||||
proofUpdate.setTheoremName("Test Update");
|
proofUpdate.setTheoremName("Test Update");
|
||||||
final ProofDto updatedProof = existingProof;
|
final Proof updatedProof = existingProof;
|
||||||
updatedProof.setTheoremName("Test Update");
|
updatedProof.setTheoremName("Test Update");
|
||||||
when(proofRepository.findById(anyInt())).thenReturn(Optional.of(existingProof));
|
when(proofRepository.findById(anyInt())).thenReturn(Optional.of(existingProof));
|
||||||
when(proofRepository.save(any(ProofDto.class))).thenReturn(updatedProof);
|
when(proofRepository.save(any(Proof.class))).thenReturn(updatedProof);
|
||||||
|
|
||||||
final ResponseEntity<ProofDto> responseEntity = proofController.updateProof(1, proofUpdate, bindingResult);
|
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, proofUpdate, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(updatedProof, responseEntity.getBody());
|
assertEquals(updatedProof, responseEntity.getBody());
|
||||||
verify(proofRepository).findById(anyInt());
|
verify(proofRepository).findById(anyInt());
|
||||||
verify(proofRepository).save(any(ProofDto.class));
|
verify(proofRepository).save(any(Proof.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateProof_bindingResultHasErrors() {
|
public void testUpdateProof_bindingResultHasErrors() {
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity<ProofDto> responseEntity = proofController.updateProof(1, createProof(), bindingResult);
|
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, createProof(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -235,7 +235,7 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateProof_proofDtoIsNull() {
|
public void testUpdateProof_proofDtoIsNull() {
|
||||||
final ResponseEntity<ProofDto> responseEntity = proofController.updateProof(1, null, bindingResult);
|
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, null, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -245,7 +245,7 @@ public class ProofControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateProof_idIsNull() {
|
public void testUpdateProof_idIsNull() {
|
||||||
final ResponseEntity<ProofDto> responseEntity = proofController.updateProof(null, createProof(), bindingResult);
|
final ResponseEntity<Proof> responseEntity = proofController.updateProof(null, createProof(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -257,12 +257,12 @@ public class ProofControllerTest {
|
|||||||
public void testUpdateProof_theoremDoesNotExist() {
|
public void testUpdateProof_theoremDoesNotExist() {
|
||||||
when(proofRepository.findById(anyInt())).thenReturn(Optional.empty());
|
when(proofRepository.findById(anyInt())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
final ResponseEntity<ProofDto> responseEntity = proofController.updateProof(1, createProof(), bindingResult);
|
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, createProof(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
||||||
verify(proofRepository, times(0)).save(any(ProofDto.class));
|
verify(proofRepository, times(0)).save(any(Proof.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -287,7 +287,7 @@ public class ProofControllerTest {
|
|||||||
verifyZeroInteractions(proofRepository);
|
verifyZeroInteractions(proofRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProofDto createProof() {
|
private Proof createProof() {
|
||||||
final List<String> referencedTheoremsList = new ArrayList<>();
|
final List<String> referencedTheoremsList = new ArrayList<>();
|
||||||
referencedTheoremsList.add("test theorem 1");
|
referencedTheoremsList.add("test theorem 1");
|
||||||
referencedTheoremsList.add("test theorem 2");
|
referencedTheoremsList.add("test theorem 2");
|
||||||
@@ -296,13 +296,13 @@ public class ProofControllerTest {
|
|||||||
referencedDefinitionsList.add("test definition 1");
|
referencedDefinitionsList.add("test definition 1");
|
||||||
referencedDefinitionsList.add("test definition 2");
|
referencedDefinitionsList.add("test definition 2");
|
||||||
|
|
||||||
final ProofDto proofDto = new ProofDto();
|
final Proof proof = new Proof();
|
||||||
proofDto.setTheoremName("Test proof");
|
proof.setTheoremName("Test proof");
|
||||||
proofDto.setBranch("Test branch");
|
proof.setBranch("Test branch");
|
||||||
proofDto.setDateCreated(new Date());
|
proof.setDateCreated(new Date());
|
||||||
proofDto.setReferencedTheorems(referencedTheoremsList);
|
proof.setReferencedTheorems(referencedTheoremsList);
|
||||||
proofDto.setReferencedDefinitions(referencedDefinitionsList);
|
proof.setReferencedDefinitions(referencedDefinitionsList);
|
||||||
|
|
||||||
return proofDto;
|
return proof;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+50
-50
@@ -1,6 +1,6 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.TheoremDto;
|
import edu.msudenver.tsp.persistence.dto.Theorem;
|
||||||
import edu.msudenver.tsp.persistence.dto.TheoremType;
|
import edu.msudenver.tsp.persistence.dto.TheoremType;
|
||||||
import edu.msudenver.tsp.persistence.repository.TheoremRepository;
|
import edu.msudenver.tsp.persistence.repository.TheoremRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -32,14 +32,14 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheorems() {
|
public void testGetAllTheorems() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theoremDto = createTheorem();
|
||||||
final List<TheoremDto> listOfTheorems = new ArrayList<>();
|
final List<Theorem> listOfTheorems = new ArrayList<>();
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
|
|
||||||
when(theoremRepository.findAll()).thenReturn(listOfTheorems);
|
when(theoremRepository.findAll()).thenReturn(listOfTheorems);
|
||||||
|
|
||||||
final ResponseEntity<Iterable<TheoremDto>> responseEntity = theoremController.getAllTheorems();
|
final ResponseEntity<Iterable<Theorem>> responseEntity = theoremController.getAllTheorems();
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -51,16 +51,16 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTheoremById() {
|
public void testGetTheoremById() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theorem = createTheorem();
|
||||||
when(theoremRepository.findById(anyInt())).thenReturn(Optional.ofNullable(theoremDto));
|
when(theoremRepository.findById(anyInt())).thenReturn(Optional.ofNullable(theorem));
|
||||||
|
|
||||||
final ResponseEntity<TheoremDto> responseEntity = theoremController.getTheoremById(1);
|
final ResponseEntity<Theorem> responseEntity = theoremController.getTheoremById(1);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(theoremDto, responseEntity.getBody());
|
assertEquals(theorem, responseEntity.getBody());
|
||||||
verify(theoremRepository).findById(anyInt());
|
verify(theoremRepository).findById(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,14 +88,14 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheoremsByBranch() {
|
public void testGetAllTheoremsByBranch() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theoremDto = createTheorem();
|
||||||
final List<TheoremDto> listOfTheorems = new ArrayList<>();
|
final List<Theorem> listOfTheorems = new ArrayList<>();
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
|
|
||||||
when(theoremRepository.findByBranch(anyString())).thenReturn(listOfTheorems);
|
when(theoremRepository.findByBranch(anyString())).thenReturn(listOfTheorems);
|
||||||
|
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByBranch("test");
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByBranch("test");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -107,7 +107,7 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheoremsByBranch_nullBranch() {
|
public void testGetAllTheoremsByBranch_nullBranch() {
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByBranch(null);
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByBranch(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -119,7 +119,7 @@ public class TheoremControllerTest {
|
|||||||
public void testGetAllTheoremsByBranch_noTheoremsFound() {
|
public void testGetAllTheoremsByBranch_noTheoremsFound() {
|
||||||
when(theoremRepository.findByBranch(anyString())).thenReturn(Collections.emptyList());
|
when(theoremRepository.findByBranch(anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByBranch("test nonexistent branch");
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByBranch("test nonexistent branch");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -128,14 +128,14 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheoremsByProvenStatus() {
|
public void testGetAllTheoremsByProvenStatus() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theoremDto = createTheorem();
|
||||||
final List<TheoremDto> listOfTheorems = new ArrayList<>();
|
final List<Theorem> listOfTheorems = new ArrayList<>();
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
|
|
||||||
when(theoremRepository.findByProvenStatus(anyBoolean())).thenReturn(listOfTheorems);
|
when(theoremRepository.findByProvenStatus(anyBoolean())).thenReturn(listOfTheorems);
|
||||||
|
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByProvenStatus(true);
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByProvenStatus(true);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -147,7 +147,7 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheoremsByProvenStatus_nullProvenStatus() {
|
public void testGetAllTheoremsByProvenStatus_nullProvenStatus() {
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByProvenStatus(null);
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByProvenStatus(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -159,7 +159,7 @@ public class TheoremControllerTest {
|
|||||||
public void testGetAllTheoremsByProvenStatus_noTheoremsFound() {
|
public void testGetAllTheoremsByProvenStatus_noTheoremsFound() {
|
||||||
when(theoremRepository.findByProvenStatus(anyBoolean())).thenReturn(Collections.emptyList());
|
when(theoremRepository.findByProvenStatus(anyBoolean())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByProvenStatus(false);
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByProvenStatus(false);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -168,14 +168,14 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheoremsByName() {
|
public void testGetAllTheoremsByName() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theoremDto = createTheorem();
|
||||||
final List<TheoremDto> listOfTheorems = new ArrayList<>();
|
final List<Theorem> listOfTheorems = new ArrayList<>();
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
listOfTheorems.add(theoremDto);
|
listOfTheorems.add(theoremDto);
|
||||||
|
|
||||||
when(theoremRepository.findByName(anyString())).thenReturn(listOfTheorems);
|
when(theoremRepository.findByName(anyString())).thenReturn(listOfTheorems);
|
||||||
|
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByName("Test Theorem");
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByName("Test Theorem");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
@@ -187,7 +187,7 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheoremsByName_nullName() {
|
public void testGetAllTheoremsByName_nullName() {
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByName(null);
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByName(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -199,7 +199,7 @@ public class TheoremControllerTest {
|
|||||||
public void testGetAllTheoremsByName_noNameFound() {
|
public void testGetAllTheoremsByName_noNameFound() {
|
||||||
when(theoremRepository.findByName(anyString())).thenReturn(Collections.emptyList());
|
when(theoremRepository.findByName(anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByName("No name");
|
final ResponseEntity<List<Theorem>> responseEntity = theoremController.getAllTheoremsByName("No name");
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -208,17 +208,17 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertTheorem() {
|
public void testInsertTheorem() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theorem = createTheorem();
|
||||||
when(theoremRepository.save(any(TheoremDto.class))).thenReturn(theoremDto);
|
when(theoremRepository.save(any(Theorem.class))).thenReturn(theorem);
|
||||||
|
|
||||||
final ResponseEntity<TheoremDto> responseEntity = theoremController.insertTheorem(theoremDto, bindingResult);
|
final ResponseEntity<Theorem> responseEntity = theoremController.insertTheorem(theorem, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertNotNull(responseEntity.getBody());
|
assertNotNull(responseEntity.getBody());
|
||||||
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
|
||||||
assertEquals(theoremDto, responseEntity.getBody());
|
assertEquals(theorem, responseEntity.getBody());
|
||||||
verify(theoremRepository).save(any(TheoremDto.class));
|
verify(theoremRepository).save(any(Theorem.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -233,10 +233,10 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertTheorem_bindingResultHasErrors() {
|
public void testInsertTheorem_bindingResultHasErrors() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final Theorem theorem = createTheorem();
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity responseEntity = theoremController.insertTheorem(theoremDto, bindingResult);
|
final ResponseEntity responseEntity = theoremController.insertTheorem(theorem, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -246,31 +246,31 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTheorem() {
|
public void testUpdateTheorem() {
|
||||||
final TheoremDto existingTheorem = createTheorem();
|
final Theorem existingTheorem = createTheorem();
|
||||||
existingTheorem.setId(1);
|
existingTheorem.setId(1);
|
||||||
existingTheorem.setVersion(1);
|
existingTheorem.setVersion(1);
|
||||||
final TheoremDto theoremUpdate = new TheoremDto();
|
final Theorem theoremUpdate = new Theorem();
|
||||||
theoremUpdate.setName("Test Update");
|
theoremUpdate.setName("Test Update");
|
||||||
final TheoremDto updatedTheorem = existingTheorem;
|
final Theorem updatedTheorem = existingTheorem;
|
||||||
updatedTheorem.setName("Test Update");
|
updatedTheorem.setName("Test Update");
|
||||||
when(theoremRepository.findById(anyInt())).thenReturn(Optional.of(existingTheorem));
|
when(theoremRepository.findById(anyInt())).thenReturn(Optional.of(existingTheorem));
|
||||||
when(theoremRepository.save(any(TheoremDto.class))).thenReturn(updatedTheorem);
|
when(theoremRepository.save(any(Theorem.class))).thenReturn(updatedTheorem);
|
||||||
|
|
||||||
final ResponseEntity<TheoremDto> responseEntity = theoremController.updateTheorem(1, theoremUpdate, bindingResult);
|
final ResponseEntity<Theorem> responseEntity = theoremController.updateTheorem(1, theoremUpdate, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertTrue(responseEntity.hasBody());
|
assertTrue(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
|
||||||
assertEquals(updatedTheorem, responseEntity.getBody());
|
assertEquals(updatedTheorem, responseEntity.getBody());
|
||||||
verify(theoremRepository).findById(anyInt());
|
verify(theoremRepository).findById(anyInt());
|
||||||
verify(theoremRepository).save(any(TheoremDto.class));
|
verify(theoremRepository).save(any(Theorem.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTheorem_bindingResultHasErrors() {
|
public void testUpdateTheorem_bindingResultHasErrors() {
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity<TheoremDto> responseEntity = theoremController.updateTheorem(1, createTheorem(), bindingResult);
|
final ResponseEntity<Theorem> responseEntity = theoremController.updateTheorem(1, createTheorem(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -280,7 +280,7 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTheorem_theoremDtoIsNull() {
|
public void testUpdateTheorem_theoremDtoIsNull() {
|
||||||
final ResponseEntity<TheoremDto> responseEntity = theoremController.updateTheorem(1, null, bindingResult);
|
final ResponseEntity<Theorem> responseEntity = theoremController.updateTheorem(1, null, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -290,7 +290,7 @@ public class TheoremControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateTheorem_idIsNull() {
|
public void testUpdateTheorem_idIsNull() {
|
||||||
final ResponseEntity<TheoremDto> responseEntity = theoremController.updateTheorem(null, createTheorem(), bindingResult);
|
final ResponseEntity<Theorem> responseEntity = theoremController.updateTheorem(null, createTheorem(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
@@ -302,12 +302,12 @@ public class TheoremControllerTest {
|
|||||||
public void testUpdateTheorem_theoremDoesNotExist() {
|
public void testUpdateTheorem_theoremDoesNotExist() {
|
||||||
when(theoremRepository.findById(anyInt())).thenReturn(Optional.empty());
|
when(theoremRepository.findById(anyInt())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
final ResponseEntity<TheoremDto> responseEntity = theoremController.updateTheorem(1, createTheorem(), bindingResult);
|
final ResponseEntity<Theorem> responseEntity = theoremController.updateTheorem(1, createTheorem(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
||||||
verify(theoremRepository, times(0)).save(any(TheoremDto.class));
|
verify(theoremRepository, times(0)).save(any(Theorem.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -332,7 +332,7 @@ public class TheoremControllerTest {
|
|||||||
verifyZeroInteractions(theoremRepository);
|
verifyZeroInteractions(theoremRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TheoremDto createTheorem() {
|
private Theorem createTheorem() {
|
||||||
final List<String> referencedTheoremsList = new ArrayList<>();
|
final List<String> referencedTheoremsList = new ArrayList<>();
|
||||||
referencedTheoremsList.add("test theorem 1");
|
referencedTheoremsList.add("test theorem 1");
|
||||||
referencedTheoremsList.add("test theorem 2");
|
referencedTheoremsList.add("test theorem 2");
|
||||||
@@ -341,14 +341,14 @@ public class TheoremControllerTest {
|
|||||||
referencedDefinitionsList.add("test definition 1");
|
referencedDefinitionsList.add("test definition 1");
|
||||||
referencedDefinitionsList.add("test definition 2");
|
referencedDefinitionsList.add("test definition 2");
|
||||||
|
|
||||||
final TheoremDto theoremDto = new TheoremDto();
|
final Theorem theorem = new Theorem();
|
||||||
theoremDto.setName("Test theorem");
|
theorem.setName("Test theorem");
|
||||||
theoremDto.setBranch("Test branch");
|
theorem.setBranch("Test branch");
|
||||||
theoremDto.setProvenStatus(true);
|
theorem.setProvenStatus(true);
|
||||||
theoremDto.setTheoremType(TheoremType.THEOREM);
|
theorem.setTheoremType(TheoremType.THEOREM);
|
||||||
theoremDto.setReferencedTheorems(referencedTheoremsList);
|
theorem.setReferencedTheorems(referencedTheoremsList);
|
||||||
theoremDto.setReferencedDefinitions(referencedDefinitionsList);
|
theorem.setReferencedDefinitions(referencedDefinitionsList);
|
||||||
|
|
||||||
return theoremDto;
|
return theorem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package edu.msudenver.tsp.services.dto;
|
package edu.msudenver.tsp.services.dto;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import edu.msudenver.tsp.persistence.dto.AccountDto;
|
|
||||||
|
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
@@ -12,8 +11,8 @@ import java.io.Serializable;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class Account extends BaseDto implements Serializable {
|
public class Account extends BaseDto implements Serializable {
|
||||||
@NotBlank(groups = AccountDto.Insert.class, message = "A username must be specified") @Size(max = 50) private String username;
|
@NotBlank(groups = edu.msudenver.tsp.persistence.dto.Account.Insert.class, message = "A username must be specified") @Size(max = 50) private String username;
|
||||||
@NotBlank(groups = AccountDto.Insert.class, message = "A password must be specified") @Size(max = 256) private String password;
|
@NotBlank(groups = edu.msudenver.tsp.persistence.dto.Account.Insert.class, message = "A password must be specified") @Size(max = 256) private String password;
|
||||||
@NotNull @SerializedName("administrator_status") private boolean administratorStatus;
|
@NotNull @SerializedName("administrator_status") private boolean administratorStatus;
|
||||||
@Temporal(TemporalType.DATE) @SerializedName("last_login") private Date lastLogin;
|
@Temporal(TemporalType.DATE) @SerializedName("last_login") private Date lastLogin;
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,24 @@
|
|||||||
package edu.msudenver.tsp.services.parser;
|
package edu.msudenver.tsp.services.parser;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.controller.DefinitionController;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import edu.msudenver.tsp.persistence.controller.NotationController;
|
|
||||||
import edu.msudenver.tsp.persistence.controller.ProofController;
|
|
||||||
import edu.msudenver.tsp.persistence.controller.TheoremController;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
class ParserService {
|
class ParserService {
|
||||||
private final DefinitionController definitionController;
|
|
||||||
private final TheoremController theoremController;
|
|
||||||
private final NotationController notationController;
|
|
||||||
private final ProofController proofController;
|
|
||||||
private Node root;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ParserService(final DefinitionController definitionController, final TheoremController theoremController,
|
|
||||||
final NotationController notationController, final ProofController proofController) {
|
|
||||||
this.definitionController = definitionController;
|
|
||||||
this.theoremController = theoremController;
|
|
||||||
this.notationController = notationController;
|
|
||||||
this.proofController = proofController;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean parseUserInput(final String userInput)
|
public boolean parseUserInput(final String userInput)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
final Node tree = parseRawInput(userInput);
|
final Node tree = parseRawInput(userInput);
|
||||||
final List<String> statements = retrieveStatements(tree);
|
retrieveStatements(tree);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(final Exception e) {
|
} catch(final Exception e) {
|
||||||
e.printStackTrace();
|
LOG.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -44,7 +27,7 @@ class ParserService {
|
|||||||
{
|
{
|
||||||
input = input.toLowerCase();
|
input = input.toLowerCase();
|
||||||
|
|
||||||
root = new Node(input, null);
|
final Node root = new Node(input, null);
|
||||||
|
|
||||||
if(input.equals(""))
|
if(input.equals(""))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package edu.msudenver.tsp.services.parser;
|
package edu.msudenver.tsp.services.parser;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.controller.DefinitionController;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -12,18 +12,14 @@ import java.util.List;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class ParserServiceTest {
|
public class ParserServiceTest {
|
||||||
|
|
||||||
private final DefinitionController definitionControllerMock = mock(DefinitionController.class);
|
@Mock private ParserService mockParserService;
|
||||||
private final ParserService mockParserService = mock(ParserService.class);
|
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks private ParserService parserService;
|
||||||
private final ParserService parserService = new ParserService(definitionControllerMock, null,
|
|
||||||
null, null);
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyStringEqualsEmptyString() {
|
public void testEmptyStringEqualsEmptyString() {
|
||||||
|
|||||||
Reference in New Issue
Block a user