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:
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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 :_ *)
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user