Improved module name <functional-area>-<Command|Query>....

Standalone services now use the Event Store Server (many tests still use the embedded server)
This commit is contained in:
Chris Richardson
2015-04-14 19:08:07 -07:00
parent d166c9b852
commit 2e31853ad2
150 changed files with 1237 additions and 109 deletions

View File

@@ -0,0 +1,14 @@
package net.chrisrichardson.eventstore.examples.bank.web
import net.chrisrichardson.eventstore.client.config.EventStoreHttpClientConfiguration
import net.chrisrichardson.eventstore.examples.bank.web.accounts.CommandSideWebAccountsConfiguration
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation._
@Configuration
@EnableAutoConfiguration
@Import(Array(classOf[CommandSideWebAccountsConfiguration], classOf[EventStoreHttpClientConfiguration]))
@ComponentScan
class AccountsCommandSideServiceConfiguration {
}

View File

@@ -0,0 +1,10 @@
package net.chrisrichardson.eventstore.examples.bank.web.main
import net.chrisrichardson.eventstore.examples.bank.web.AccountsCommandSideServiceConfiguration
import org.springframework.boot.SpringApplication
object AccountsCommandSideServiceMain {
def main(args: Array[String]) : Unit = SpringApplication.run(classOf[AccountsCommandSideServiceConfiguration], args :_ *)
}

View File

@@ -0,0 +1,32 @@
package net.chrisrichardson.eventstore.examples.bank.web
import net.chrisrichardson.eventstore.examples.bank.web.accounts.controllers.{CreateAccountRequest, CreateAccountResponse}
import org.junit.Assert
import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner
import org.springframework.boot.SpringApplication
import org.springframework.web.client.RestTemplate
@RunWith(classOf[JUnitRunner])
class AccountsCommandSideServiceIntegrationTest extends FlatSpec {
val sa = new SpringApplication(classOf[AccountsCommandSideServiceTestConfiguration])
val ctx = sa.run()
// var server = ctx.getBean(classOf[EmbeddedServletContainer])
val port = 8080
val baseUrl = s"http://localhost:$port/"
val restTemplate = ctx.getBean(classOf[RestTemplate])
it should "create account" in {
val CreateAccountResponse(accountId) = restTemplate.postForEntity(s"$baseUrl/accounts", CreateAccountRequest(BigDecimal(500)), classOf[CreateAccountResponse]).getBody
Assert.assertNotNull(accountId)
}
}

View File

@@ -0,0 +1,26 @@
package net.chrisrichardson.eventstore.examples.bank.web
import com.fasterxml.jackson.databind.ObjectMapper
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.{Bean, Import, Configuration}
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
import org.springframework.web.client.RestTemplate
import scala.collection.JavaConversions._
@Configuration
@Import(Array(classOf[AccountsCommandSideServiceConfiguration]))
class AccountsCommandSideServiceTestConfiguration {
@Bean
def restTemplate(scalaObjectMapper: ObjectMapper) = {
val restTemplate = new RestTemplate()
restTemplate.getMessageConverters foreach {
case mc: MappingJackson2HttpMessageConverter =>
mc.setObjectMapper(scalaObjectMapper)
case _ =>
}
restTemplate
}
}