diff --git a/.travis.yml b/.travis.yml index 1cc6dfe..9bae6c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - secure: kWYqUiO9op6e5u+5ygCSfUVnuTVvXuLYETnllCB5tqcbDN2bO+HUJiS48yA+944KpbnhGVT+6sv1eCwTkrKdTZ7pNmun9IzBIRCrelW+duOv4YCSEYe0mVBUWk7qIDimaSeOLt9Ifz1EsWCJSh+09j9sdaIUbzBmTnNBErl3Jkw3hvBpvR0QFftI8PB3M3w6b4DFr2rR5cRTwAIL06I/awLA+U4/EGZ3zI5gIXTO/08GJebLaGKTjD5gO0nVHT0gptKvJxLfMjUiEZwc3e5DZKq+SMClxmWcw285HPziRlqiYi8MXFU4zVPS6hCDrvmWEIbhS0DNh4yq9johkw3CBuCQAznNlGGXX21boC4g+RP0+WrdgUMT3uN/5LFm4Jw0EroYrjXmP/wnyCxBRDkqINBYgdGU8KnnuTSm/oaAVA/1iuTEaOXuM8foGnbkP/QJOzWsKgK4feYi6xMsyMHTtxwZWiLgpX4Ozp1szmsRjSLyWPRbdca1SBEzIkoJ0bRncuRRJ1MhEeX8qbEFmht8sD/CzxtDX4O1EhvJiYqe/3nwge2HLM2oqPkdXRN0527XZVJD8IG0O7qrCQqilisGHaDUNhtkWwKMvHc9qpHbxEGj5g3fvafPX82D1DwlAfViQGkAlku2yg0C/NMRApPJgPZrKdCOKPp2cEe9T6Imvrk= addons: - sauce_connect: true + - selenium before_install: - npm install -g grunt-cli diff --git a/README.md b/README.md index 40430a0..6537b92 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://travis-ci.org/BooksterTeam/Bookster2.svg?branch=master)](https://travis-ci.org/BooksterTeam/Bookster2) +[![Quality Gate](http://193.196.7.25/api/badges/gate?key=io.bookster:bookster-2)](http://193.196.7.25/overview?id=5973) # Bookster2 This application was generated using JHipster, you can find documentation and help at [https://jhipster.github.io](https://jhipster.github.io). diff --git a/build.gradle b/build.gradle index 0823cc7..bd4eb96 100644 --- a/build.gradle +++ b/build.gradle @@ -18,17 +18,20 @@ buildscript { } } + apply plugin: 'java' -sourceCompatibility=1.8 -targetCompatibility=1.8 +sourceCompatibility = 1.8 +targetCompatibility = 1.8 apply plugin: 'maven' apply plugin: 'spring-boot' apply plugin: 'war' apply plugin: 'propdeps' +apply plugin: 'sonar-runner' +apply plugin: 'jacoco' defaultTasks 'bootRun' bootRepackage { - mainClass = 'io.bookster.Bookster2App' + mainClass = 'io.bookster.Bookster2App' } war { @@ -111,7 +114,7 @@ dependencies { compile group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: dropwizard_metrics_version compile group: 'io.dropwizard.metrics', name: 'metrics-servlet', version: dropwizard_metrics_version compile group: 'io.dropwizard.metrics', name: 'metrics-json', version: dropwizard_metrics_version - compile (group: 'io.dropwizard.metrics', name: 'metrics-servlets', version: dropwizard_metrics_version) { + compile(group: 'io.dropwizard.metrics', name: 'metrics-servlets', version: dropwizard_metrics_version) { exclude(module: 'metrics-healthchecks') } compile(group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: logstash_logback_encoder_version) { @@ -123,10 +126,10 @@ dependencies { compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate4', version: jackson_version compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jackson_version compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jackson_version - compile (group: 'com.ryantenney.metrics', name: 'metrics-spring', version: metrics_spring_version) { + compile(group: 'com.ryantenney.metrics', name: 'metrics-spring', version: metrics_spring_version) { exclude(module: 'metrics-core') exclude(module: 'metrics-healthchecks') - } + } compile(group: 'com.zaxxer', name: 'HikariCP', version: HikariCP_version) { exclude(module: 'tools') } @@ -136,13 +139,13 @@ dependencies { compile group: 'javax.transaction', name: 'javax.transaction-api' compile group: 'org.apache.geronimo.javamail', name: 'geronimo-javamail_1.4_mail', version: geronimo_javamail_1_4_mail_version compile group: 'org.hibernate', name: 'hibernate-core', version: hibernate_entitymanager_version - - compile (group: 'org.hibernate', name: 'hibernate-ehcache') { + + compile(group: 'org.hibernate', name: 'hibernate-ehcache') { exclude(module: 'ehcache-core') } compile group: 'org.hibernate', name: 'hibernate-envers' compile group: 'org.hibernate', name: 'hibernate-validator' - compile (group: 'org.liquibase', name: 'liquibase-core', version: liquibase_core_version) { + compile(group: 'org.liquibase', name: 'liquibase-core', version: liquibase_core_version) { exclude(module: 'jetty-servlet') } compile group: 'com.mattbertolini', name: 'liquibase-slf4j', version: liquibase_slf4j_version @@ -166,12 +169,12 @@ dependencies { compile group: 'org.springframework.security', name: 'spring-security-config', version: spring_security_version compile group: 'org.springframework.security', name: 'spring-security-data', version: spring_security_version compile group: 'org.springframework.security', name: 'spring-security-web', version: spring_security_version - compile group: 'org.springframework.security', name: 'spring-security-messaging', version: spring_security_version + compile group: 'org.springframework.security', name: 'spring-security-messaging', version: spring_security_version - compile(group: 'io.springfox', name: 'springfox-swagger2', version: springfox_version){ + compile(group: 'io.springfox', name: 'springfox-swagger2', version: springfox_version) { exclude module: 'mapstruct' } - + compile group: 'mysql', name: 'mysql-connector-java' compile group: 'com.h2database', name: 'h2' compile group: 'fr.ippon.spark.metrics', name: 'metrics-spark-reporter', version: metrics_spark_reporter_version @@ -181,14 +184,14 @@ dependencies { testCompile group: 'info.cukes', name: 'cucumber-junit', version: cucumber_version testCompile group: 'info.cukes', name: 'cucumber-spring', version: cucumber_version testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test' - testCompile group: 'org.assertj', name: 'assertj-core', version: assertj_core_version + testCompile group: 'org.assertj', name: 'assertj-core', version: assertj_core_version testCompile group: 'junit', name: 'junit' testCompile group: 'org.mockito', name: 'mockito-core' testCompile group: 'com.mattbertolini', name: 'liquibase-slf4j', version: liquibase_slf4j_version testCompile group: 'org.hamcrest', name: 'hamcrest-library' - - - optional group: 'org.springframework.boot', name:'spring-boot-configuration-processor', version: spring_boot_version + + + optional group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version: spring_boot_version //jhipster-needle-gradle-dependency - JHipster will add additional dependencies here testCompile "org.seleniumhq.selenium:selenium-java:2.48.2" } @@ -205,3 +208,14 @@ task wrapper(type: Wrapper) { task stage(dependsOn: 'bootRepackage') { } + +sonarRunner { + sonarProperties { + property "sonar.host.url", "http://193.196.7.25/" + property "sonar.projectName", "bookster2" + property "sonar.projectVersions", "1.0.0" + property "sonar.sources", "src/main/java/io/bookster" + property "sourceEncoding", "UTF-8" + //property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/test.exec" + } +} \ No newline at end of file diff --git a/src/main/java/io/bookster/domain/enumeration/AcceptRequest.java b/src/main/java/io/bookster/domain/enumeration/AcceptRequest.java new file mode 100644 index 0000000..9454ed3 --- /dev/null +++ b/src/main/java/io/bookster/domain/enumeration/AcceptRequest.java @@ -0,0 +1,20 @@ +package io.bookster.domain.enumeration; + +import io.bookster.domain.LendingRequest; + +/** + * Created on 08/05/16 + * author: nixoxo + */ +public class AcceptRequest implements Request { + + public AcceptRequest(){ + + } + + @Override + public LendingRequest process(LendingRequest lendingRequest) { + lendingRequest.setStatus(RequestStatus.ACCEPTED); + return lendingRequest; + } +} diff --git a/src/main/java/io/bookster/domain/enumeration/CancelRequest.java b/src/main/java/io/bookster/domain/enumeration/CancelRequest.java new file mode 100644 index 0000000..6208af1 --- /dev/null +++ b/src/main/java/io/bookster/domain/enumeration/CancelRequest.java @@ -0,0 +1,20 @@ +package io.bookster.domain.enumeration; + +import io.bookster.domain.LendingRequest; + +/** + * Created on 08/05/16 + * author: nixoxo + */ +public class CancelRequest implements Request { + + public CancelRequest(){ + + } + + @Override + public LendingRequest process(LendingRequest lendingRequest) { + lendingRequest.setStatus(RequestStatus.CANCELED); + return lendingRequest; + } +} diff --git a/src/main/java/io/bookster/domain/enumeration/PendingRequest.java b/src/main/java/io/bookster/domain/enumeration/PendingRequest.java new file mode 100644 index 0000000..b994e1a --- /dev/null +++ b/src/main/java/io/bookster/domain/enumeration/PendingRequest.java @@ -0,0 +1,22 @@ +package io.bookster.domain.enumeration; + +import io.bookster.domain.LendingRequest; + +/** + * Created on 08/05/16 + * author: nixoxo + */ +public class PendingRequest implements Request { + + public PendingRequest() { + + } + + @Override + public LendingRequest process(LendingRequest lendingRequest) { + + lendingRequest.setStatus(RequestStatus.PENDING); + + return lendingRequest; + } +} diff --git a/src/main/java/io/bookster/domain/enumeration/RejectRequest.java b/src/main/java/io/bookster/domain/enumeration/RejectRequest.java new file mode 100644 index 0000000..b088f07 --- /dev/null +++ b/src/main/java/io/bookster/domain/enumeration/RejectRequest.java @@ -0,0 +1,15 @@ +package io.bookster.domain.enumeration; + +import io.bookster.domain.LendingRequest; + +/** + * Created on 08/05/16 + * author: nixoxo + */ +public class RejectRequest implements Request { + @Override + public LendingRequest process(LendingRequest lendingRequest) { + lendingRequest.setStatus(RequestStatus.REJECTED); + return lendingRequest; + } +} diff --git a/src/main/java/io/bookster/domain/enumeration/Request.java b/src/main/java/io/bookster/domain/enumeration/Request.java new file mode 100644 index 0000000..30fcf9f --- /dev/null +++ b/src/main/java/io/bookster/domain/enumeration/Request.java @@ -0,0 +1,13 @@ +package io.bookster.domain.enumeration; + +import io.bookster.domain.LendingRequest; + +/** + * Created on 08/05/16 + * author: nixoxo + */ +public interface Request { + + public LendingRequest process(LendingRequest lendingRequest); + +} diff --git a/src/main/java/io/bookster/domain/enumeration/RequestFactory.java b/src/main/java/io/bookster/domain/enumeration/RequestFactory.java new file mode 100644 index 0000000..de6e1ce --- /dev/null +++ b/src/main/java/io/bookster/domain/enumeration/RequestFactory.java @@ -0,0 +1,34 @@ +package io.bookster.domain.enumeration; + +/** + * Created on 08/05/16 + * author: nixoxo + */ +public class RequestFactory { + + private static RequestFactory requestFactory = new RequestFactory(); + + private RequestFactory() { + } + + public static Request pendingRequest() { + return new PendingRequest(); + } + + public static Request cancelRequest() { + return new CancelRequest(); + } + + public static Request acceptRequest(){ + return new AcceptRequest(); + } + + public static Request rejectRequest(){ + return new RejectRequest(); + } + + + public static RequestFactory getRequestFactory() { + return requestFactory; + } +} diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index f271614..9acc43a 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -149,17 +149,6 @@ - - - - - - - - - - - @@ -186,6 +175,17 @@ + + + + + + + + + + + @@ -206,18 +206,18 @@ - - - + + + - - + + diff --git a/src/test/features/books.feature b/src/test/features/books.feature index 47b2ea9..4a466f7 100644 --- a/src/test/features/books.feature +++ b/src/test/features/books.feature @@ -4,3 +4,7 @@ Feature: This should describe the feature of displaying books Given user authenticated and clicked on the market Then books are shown Then one book has the id 'details1001' + + Scenario: Retrieve no books + Given user authenticated and clicked on the market + Then no books are shown \ No newline at end of file diff --git a/src/test/features/copy.feature b/src/test/features/copy.feature index 03c88e1..10884ef 100644 --- a/src/test/features/copy.feature +++ b/src/test/features/copy.feature @@ -5,3 +5,9 @@ Feature: This should describe the feature of adding a copy Given a modal does pop up Given add a copy for the book with the id '1001' Then a copy has been added + + Scenario: Add copy failed because book does not exist + Given user authenticated and navigated to the copys + Given a modal does pop up + Given add a copy for the book with the id '345678' + Then no copy has been added diff --git a/src/test/java/io/bookster/config/BaseDriverIntegration.java b/src/test/java/io/bookster/config/BaseDriverIntegration.java index 6b6c4d2..7cf3d24 100644 --- a/src/test/java/io/bookster/config/BaseDriverIntegration.java +++ b/src/test/java/io/bookster/config/BaseDriverIntegration.java @@ -67,8 +67,8 @@ private WebDriver firefoxDriver(){ protected void authenticate(WebDriver browser) throws InterruptedException { browser.get(server); Thread.sleep(500); - browser.findElement(id("account-menu")).click(); - browser.findElement(id("login")).click(); + // browser.findElement(id("account-menu")).click(); +// browser.findElement(id("login")).click(); browser.findElement(id("username")).sendKeys("admin"); browser.findElement(id("password")).sendKeys("admin"); WebElement loginForm = browser.findElement(id("login-button")); diff --git a/src/test/java/io/bookster/cucumber/CucumberTest.java b/src/test/java/io/bookster/cucumber/CucumberTest.java index bd80769..ffbb4b0 100644 --- a/src/test/java/io/bookster/cucumber/CucumberTest.java +++ b/src/test/java/io/bookster/cucumber/CucumberTest.java @@ -7,7 +7,7 @@ import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) -@CucumberOptions(plugin = "pretty", features = "src/test/features/register.feature") +@CucumberOptions(plugin = "pretty", features = "src/test/features/books.feature") public class CucumberTest { } diff --git a/src/test/java/io/bookster/cucumber/stepdefs/BooksSteps.java b/src/test/java/io/bookster/cucumber/stepdefs/BooksSteps.java index f016eb3..1f5a1af 100644 --- a/src/test/java/io/bookster/cucumber/stepdefs/BooksSteps.java +++ b/src/test/java/io/bookster/cucumber/stepdefs/BooksSteps.java @@ -1,12 +1,15 @@ package io.bookster.cucumber.stepdefs; +import cucumber.api.PendingException; import cucumber.api.java.After; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import io.bookster.config.BaseDriverIntegration; +import org.hamcrest.Matchers; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.openqa.selenium.By.id; @@ -44,4 +47,9 @@ public void oneBookHasTheIdDetails(int bookid) throws Throwable { public void tearDown(){ closeBrowser(); } + + @Then("^no books are shown$") + public void noBooksAreShown() throws Throwable { + + } } diff --git a/src/test/java/io/bookster/cucumber/stepdefs/CopysSteps.java b/src/test/java/io/bookster/cucumber/stepdefs/CopysSteps.java index f0f8684..9f1c0d9 100644 --- a/src/test/java/io/bookster/cucumber/stepdefs/CopysSteps.java +++ b/src/test/java/io/bookster/cucumber/stepdefs/CopysSteps.java @@ -1,5 +1,6 @@ package io.bookster.cucumber.stepdefs; +import cucumber.api.PendingException; import cucumber.api.java.After; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; @@ -47,4 +48,9 @@ public void aCopyHasBeenAdded() throws Throwable { public void tearDown() throws Exception { closeBrowser(); } + + @Then("^no copy has been added$") + public void noCopyHasBeenAdded() throws Throwable { + Thread.sleep(500); + } } \ No newline at end of file