Skip to content

Instantly share code, notes, and snippets.

import akka.actor.testkit.typed.scaladsl.ActorTestKit
import akka.stream.scaladsl.{Sink, Source}
import org.scalatest.flatspec.AnyFlatSpecLike
import scala.concurrent.Future
//akka 2.6.5
//zio 1.0.3.5-RC
class PublisherTest extends AnyFlatSpecLike {
scenario-name: "Lukasz orders XL margarita on crust with chees to his default addrress"
given {
users: [{name: "Lukasz", address: {line1: "Elm Street", line1:"12", city: "Warsaw"}}]
funds: [{user: "Lukasz", funds: "200.00"}]
}
when {
make-orders: [
{
order-name: "Lukasz's 1st order", user: "Lukasz", items: {
package com.zuchos.pizzeria
import com.zuchos.pizzeria.PizzaOrderingService.Composition.PredefinedComposition
import com.zuchos.pizzeria.PizzaOrderingService.{Composition, CompositionId, Crust, Size}
import com.zuchos.pizzeria.PizzaOrderingService.OrderedItem.Pizza
import org.scalatest.{EitherValues, FlatSpec, Matchers}
import org.scalatest.concurrent.{Eventually, IntegrationPatience, ScalaFutures}
class PizzaOrderingServiceSpec extends FlatSpec with ScalaFutures with EitherValues with Eventually with Matchers with IntegrationPatience {
trait AcceptanceSpec
extends FlatSpecLike
with BeforeAndAfterEach
with Matchers
with LazyLogging
with AbstractPatienceConfiguration
abstract class StoreAcceptanceSpec
extends TestKit(ActorSystem("StoreAcceptanceSpec"))
with AcceptanceSpec
import org.scalatest.{BeforeAndAfterEach, FlatSpecLike, Suite}
trait BaseSpec extends Suite with BeforeAndAfterEach {
override protected def beforeEach(): Unit = {
super.beforeEach()
println("Before Each Base Spec")
}
}
abstract class ExtendedBaseSpec(val name:String) extends BaseSpec {
override protected def beforeEach(): Unit = {
trait AcceptanceSpec
extends FlatSpecLike
with TestFutureHelpers
with ScalaFutures
with BeforeAndAfterAll
with OptionValues
with TryValues
with EitherValues
with Eventually
with Matchers
prettifier.isValid("HPJD-72036-HAPK-58077") should be(true)
prettifiedWithLeading.toIdSeed("AAAA-00000-AAAA-00013") should be(Right(1L))
class IdPrettifier(
encoder: Codec = new AlphabetCodec(Alphabet.Base23),
partsSize: Int = 5,
delimiter: Char = '-',
leadingZeros: Boolean = true
)
//create instance of it
val generator:StringIdGenerator = PrettyIdGenerator.singleNode
//generate ids
val stringId = generator.nextId()
stringId shouldNot be(empty)
stringId should fullyMatch regex """[A-Z]{4}-[0-9]{5}-[A-Z]{4}-[0-9]{5}"""
//or it might be used just for encoding existing ids
val prettifier = IdPrettifier.default