• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PersistentEntityTestDriver类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver的典型用法代码示例。如果您正苦于以下问题:Java PersistentEntityTestDriver类的具体用法?Java PersistentEntityTestDriver怎么用?Java PersistentEntityTestDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PersistentEntityTestDriver类属于com.lightbend.lagom.javadsl.testkit包,在下文中一共展示了PersistentEntityTestDriver类的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testHelloWorld

点赞 3

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testHelloWorld() {
  PersistentEntityTestDriver<HelloCommand, HelloEvent, HelloState> driver = new PersistentEntityTestDriver<>(system,
      new HelloEntity(), "world-1");

  Outcome<HelloEvent, HelloState> outcome1 = driver.run(new Hello("Alice", Optional.empty()));
  assertEquals("Hello, Alice!", outcome1.getReplies().get(0));
  assertEquals(Collections.emptyList(), outcome1.issues());

  Outcome<HelloEvent, HelloState> outcome2 = driver.run(new UseGreetingMessage("Hi"),
      new Hello("Bob", Optional.empty()));
  assertEquals(1, outcome2.events().size());
  assertEquals(new GreetingMessageChanged("Hi"), outcome2.events().get(0));
  assertEquals("Hi", outcome2.state().message);
  assertEquals(Done.getInstance(), outcome2.getReplies().get(0));
  assertEquals("Hi, Bob!", outcome2.getReplies().get(1));
  assertEquals(2, outcome2.getReplies().size());
  assertEquals(Collections.emptyList(), outcome2.issues());
}
 

开发者ID:MarioAriasC,
项目名称:lagomkotlin,
代码行数:20,
代码来源:HelloEntityTest.java

示例2: testHelloWorld

点赞 3

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testHelloWorld() {
    PersistentEntityTestDriver<HelloCommand, HelloEvent, HelloState> driver = new PersistentEntityTestDriver<>(system,
            new HelloEntity(), "world-1");

    Outcome<HelloEvent, HelloState> outcome1 = driver.run(new Hello("Alice", Optional.empty()));
    assertEquals("Hello, Alice!", outcome1.getReplies().get(0));
    assertEquals(Collections.emptyList(), outcome1.issues());

    Outcome<HelloEvent, HelloState> outcome2 = driver.run(new UseGreetingMessage("Hi"),
            new Hello("Bob", Optional.empty()));
    assertEquals(1, outcome2.events().size());
    assertEquals(new GreetingMessageChanged("Hi"), outcome2.events().get(0));
    assertEquals("Hi", outcome2.state().message);
    assertEquals(Done.getInstance(), outcome2.getReplies().get(0));
    assertEquals("Hi, Bob!", outcome2.getReplies().get(1));
    assertEquals(2, outcome2.getReplies().size());
    assertEquals(Collections.emptyList(), outcome2.issues());
}
 

开发者ID:jvz,
项目名称:lagom-example,
代码行数:20,
代码来源:HelloEntityTest.java

示例3: increaseInventory

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void increaseInventory() {

    PersistentEntityTestDriver<InventoryCommand, PEInventoryEvent, InventoryState> driver =
            new PersistentEntityTestDriver<>(system, new InventoryEntity(), "test-id");

    Outcome<PEInventoryEvent, InventoryState> outcome =
            driver.run(new IncreaseInventory("oranges", UUID.randomUUID(), 1000));

    assertEquals( new Integer(1000), outcome.getReplies().get(0));
}
 

开发者ID:ignasi35,
项目名称:lagom-java-workshop,
代码行数:12,
代码来源:InventoryEntityTest.java

示例4: decreaseInventory

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void decreaseInventory() {
    PersistentEntityTestDriver<InventoryCommand, PEInventoryEvent, InventoryState> driver =
            new PersistentEntityTestDriver<>(system, new InventoryEntity(), "test-id");

    UUID orangesId = UUID.randomUUID();
    IncreaseInventory add1000 = new IncreaseInventory("oranges", orangesId, 1000);
    DecreaseInventory remove100 = new DecreaseInventory(orangesId, 100);
    Outcome<PEInventoryEvent, InventoryState> outcome =
            driver.run(add1000, remove100);

    assertEquals( new Integer(1000), outcome.getReplies().get(0));
    assertEquals( new Integer(900), outcome.getReplies().get(1));
}
 

开发者ID:ignasi35,
项目名称:lagom-java-workshop,
代码行数:15,
代码来源:InventoryEntityTest.java

示例5: decreaseInventoryBelowStock

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void decreaseInventoryBelowStock() {
    PersistentEntityTestDriver<InventoryCommand, PEInventoryEvent, InventoryState> driver =
            new PersistentEntityTestDriver<>(system, new InventoryEntity(), "test-id");

    UUID orangesId = UUID.randomUUID();
    IncreaseInventory add10 = new IncreaseInventory("oranges", orangesId, 10);
    DecreaseInventory remove11 = new DecreaseInventory(orangesId, 100);
    Outcome<PEInventoryEvent, InventoryState> outcome =
            driver.run(add10, remove11);

    assertEquals( new Integer(10), outcome.getReplies().get(0));
    assertEquals( new InsuffucientStock(orangesId), outcome.getReplies().get(1));
}
 

开发者ID:ignasi35,
项目名称:lagom-java-workshop,
代码行数:15,
代码来源:InventoryEntityTest.java

示例6: addItems

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void addItems() {
    UUID bid = UUID.randomUUID();
    UUID orangeId = UUID.randomUUID();
    UUID bananaId = UUID.randomUUID();


    BasketCommand.AddItem cmd1 = new BasketCommand.AddItem(orangeId, 3);
    BasketCommand.AddItem cmd2 = new BasketCommand.AddItem(bananaId, 1);
    BasketCommand.GetBasket cmd3 = BasketCommand.GetBasket.INSTANCE;

    PersistentEntityTestDriver<BasketCommand, PEBasketEvent, BasketState> driver =
            new PersistentEntityTestDriver<>(system, new BasketEntity(), bid.toString());


    // add some oranges
    Outcome<PEBasketEvent, BasketState> outcome1 = driver.run(cmd1);
    assertEquals(Done.getInstance(), outcome1.getReplies().get(0));
    assertEquals(Collections.emptyList(), outcome1.issues());

    // and then add some bananas. Finally get the basket.
    Outcome<PEBasketEvent, BasketState> outcome3 = driver.run(cmd2, cmd3);

    PSequence<DomainBasketItem> items = TreePVector.<DomainBasketItem>empty()
            .plus(new DomainBasketItem(orangeId, 3))
            .plus(new DomainBasketItem(bananaId, 1));
    BasketState expected = new BasketState(items, false);
    assertEquals(expected, outcome3.getReplies().get(1));
    assertEquals(Collections.emptyList(), outcome1.issues());

}
 

开发者ID:ignasi35,
项目名称:lagom-java-workshop,
代码行数:32,
代码来源:BasketEntityTest.java

示例7: testCreateUser

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testCreateUser() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");

  Outcome<FriendEvent, FriendState> outcome = driver.run(
      new CreateUser(new User("alice", "Alice")));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals("alice", ((UserCreated) outcome.events().get(0)).userId);
  assertEquals("Alice", ((UserCreated) outcome.events().get(0)).name);
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:lagom,
项目名称:lagom-java-chirper-example,
代码行数:13,
代码来源:FriendEntityTest.java

示例8: testRejectDuplicateCreate

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testRejectDuplicateCreate() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  driver.run(new CreateUser(new User("alice", "Alice")));

  Outcome<FriendEvent, FriendState> outcome = driver.run(
      new CreateUser(new User("alice", "Alice")));
  assertEquals(PersistentEntity.InvalidCommandException.class, outcome.getReplies().get(0).getClass());
  assertEquals(Collections.emptyList(), outcome.events());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:lagom,
项目名称:lagom-java-chirper-example,
代码行数:13,
代码来源:FriendEntityTest.java

示例9: testCreateUserWithInitialFriends

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testCreateUserWithInitialFriends() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");

  TreePVector<String> friends = TreePVector.<String>empty().plus("bob").plus("peter");
  Outcome<FriendEvent, FriendState> outcome = driver.run(
      new CreateUser(new User("alice", "Alice", Optional.of(friends))));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals("alice", ((UserCreated) outcome.events().get(0)).userId);
  assertEquals("bob", ((FriendAdded) outcome.events().get(1)).friendId);
  assertEquals("peter", ((FriendAdded) outcome.events().get(2)).friendId);
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:lagom,
项目名称:lagom-java-chirper-example,
代码行数:15,
代码来源:FriendEntityTest.java

示例10: testAddFriend

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testAddFriend() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  driver.run(new CreateUser(new User("alice", "Alice")));

  Outcome<FriendEvent, FriendState> outcome = driver.run(new AddFriend("bob"), new AddFriend("peter"));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals("bob", ((FriendAdded) outcome.events().get(0)).friendId);
  assertEquals("peter", ((FriendAdded) outcome.events().get(1)).friendId);
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:lagom,
项目名称:lagom-java-chirper-example,
代码行数:13,
代码来源:FriendEntityTest.java

示例11: testAddDuplicateFriend

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testAddDuplicateFriend() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  driver.run(new CreateUser(new User("alice", "Alice")));
  driver.run(new AddFriend("bob"), new AddFriend("peter"));

  Outcome<FriendEvent, FriendState> outcome = driver.run(new AddFriend("bob"));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals(Collections.emptyList(), outcome.events());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:lagom,
项目名称:lagom-java-chirper-example,
代码行数:13,
代码来源:FriendEntityTest.java

示例12: testGetUser

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testGetUser() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  User alice = new User("alice", "Alice");
  driver.run(new CreateUser(alice));

  Outcome<FriendEvent, FriendState> outcome = driver.run(new GetUser());
  assertEquals(new GetUserReply(Optional.of(alice)), outcome.getReplies().get(0));
  assertEquals(Collections.emptyList(), outcome.events());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:lagom,
项目名称:lagom-java-chirper-example,
代码行数:13,
代码来源:FriendEntityTest.java

示例13: testAddChirp

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testAddChirp() {
    ChirpTopicStub topic = new ChirpTopicStub();
    PersistentEntityTestDriver<ChirpTimelineCommand, ChirpTimelineEvent, NotUsed> driver =
            new PersistentEntityTestDriver<>(system, new ChirpTimelineEntity(topic), "user-1");

    Chirp chirp = new Chirp("user-1", "Hello, world");

    PersistentEntityTestDriver.Outcome<ChirpTimelineEvent, NotUsed> outcome =
            driver.run(new AddChirp(chirp));
    assertEquals(Done.getInstance(), outcome.getReplies().get(0));
    assertEquals(chirp, ((ChirpTimelineEvent.ChirpAdded) outcome.events().get(0)).chirp);
    assertEquals(chirp, topic.chirps.get(0));
    assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:lagom,
项目名称:lagom-java-chirper-example,
代码行数:16,
代码来源:ChirpTimelineEntityTest.java

示例14: testCreateUser

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testCreateUser() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");

  Outcome<FriendEvent, FriendState> outcome = driver.run(
       CreateUser.of(User.of("alice", "Alice")));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals("alice", ((UserCreated) outcome.events().get(0)).getUserId());
  assertEquals("Alice", ((UserCreated) outcome.events().get(0)).getName());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:13,
代码来源:FriendEntityTest.java

示例15: testRejectDuplicateCreate

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testRejectDuplicateCreate() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  driver.run(CreateUser.of(User.of("alice", "Alice")));

  Outcome<FriendEvent, FriendState> outcome = driver.run(
      CreateUser.of(User.of("alice", "Alice")));
  assertEquals(PersistentEntity.InvalidCommandException.class, outcome.getReplies().get(0).getClass());
  assertEquals(Collections.emptyList(), outcome.events());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:13,
代码来源:FriendEntityTest.java

示例16: testCreateUserWithInitialFriends

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testCreateUserWithInitialFriends() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");

  TreePVector<String> friends = TreePVector.<String>empty().plus("bob").plus("peter");
  Outcome<FriendEvent, FriendState> outcome = driver.run(
      CreateUser.of(AbstractUser.of("alice", "Alice", Optional.of(friends))));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals("alice", ((UserCreated) outcome.events().get(0)).getUserId());
  assertEquals("bob", ((FriendAdded) outcome.events().get(1)).getFriendId());
  assertEquals("peter", ((FriendAdded) outcome.events().get(2)).getFriendId());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:15,
代码来源:FriendEntityTest.java

示例17: testAddFriend

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testAddFriend() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  driver.run(CreateUser.of(User.of("alice", "Alice")));

  Outcome<FriendEvent, FriendState> outcome = driver.run(AddFriend.of("bob"), AddFriend.of("peter"));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals("bob", ((FriendAdded) outcome.events().get(0)).getFriendId());
  assertEquals("peter", ((FriendAdded) outcome.events().get(1)).getFriendId());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:13,
代码来源:FriendEntityTest.java

示例18: testAddDuplicateFriend

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testAddDuplicateFriend() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  driver.run(CreateUser.of(User.of("alice", "Alice")));
  driver.run(AddFriend.of("bob"), AddFriend.of("peter"));

  Outcome<FriendEvent, FriendState> outcome = driver.run(AddFriend.of("bob"));
  assertEquals(Done.getInstance(), outcome.getReplies().get(0));
  assertEquals(Collections.emptyList(), outcome.events());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:13,
代码来源:FriendEntityTest.java

示例19: testGetUser

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testGetUser() {
  PersistentEntityTestDriver<FriendCommand, FriendEvent, FriendState> driver = new PersistentEntityTestDriver<>(
      system, new FriendEntity(), "user-1");
  User alice = User.of("alice", "Alice");
  driver.run(CreateUser.of(alice));

  Outcome<FriendEvent, FriendState> outcome = driver.run(GetUser.of());
  assertEquals(GetUserReply.of(Optional.of(alice)), outcome.getReplies().get(0));
  assertEquals(Collections.emptyList(), outcome.events());
  assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:13,
代码来源:FriendEntityTest.java

示例20: testAddFavorite

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testAddFavorite() {
    PersistentEntityTestDriver<FavoriteCommand, FavoriteEvent, FavoriteState> driver =
        new PersistentEntityTestDriver<>(system, new FavoriteEntity(), "user-1");

    PersistentEntityTestDriver.Outcome<FavoriteEvent, FavoriteState> outcome =
        driver.run(AddFavorite.of("user-1", "test-chirp-id"));

    assertEquals(Done.getInstance(), outcome.getReplies().get(0));
    Assert.assertEquals("user-1", ((FavoriteAdded) outcome.events().get(0)).getUserId());
    Assert.assertEquals("test-chirp-id", ((FavoriteAdded) outcome.events().get(0)).getFavoriteId());
    assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:14,
代码来源:FavoriteEntityTest.java

示例21: testDeleteFavorite

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testDeleteFavorite() {
    PersistentEntityTestDriver<FavoriteCommand, FavoriteEvent, FavoriteState> driver =
            new PersistentEntityTestDriver<>(system, new FavoriteEntity(), "user-1");

    PersistentEntityTestDriver.Outcome<FavoriteEvent, FavoriteState> outcome =
            driver.run(DeleteFavorite.of("user-1", "test-chirp-id"));

    assertEquals(Done.getInstance(), outcome.getReplies().get(0));
    Assert.assertEquals("user-1", ((FavoriteDeleted) outcome.events().get(0)).getUserId());
    Assert.assertEquals("test-chirp-id", ((FavoriteDeleted) outcome.events().get(0)).getFavoriteId());
    assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:14,
代码来源:FavoriteEntityTest.java

示例22: testGetFavoritesWhenNotHaveAnyFavorites

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Test
public void testGetFavoritesWhenNotHaveAnyFavorites() {
    PersistentEntityTestDriver<FavoriteCommand, FavoriteEvent, FavoriteState> driver =
            new PersistentEntityTestDriver<>(system, new FavoriteEntity(), "user-1");

    PersistentEntityTestDriver.Outcome<FavoriteEvent, FavoriteState> outcome =
            driver.run(GetFavorites.of());

    Assert.assertEquals(GetFavoritesReply.builder().build(), outcome.getReplies().get(0));
    assertEquals(Collections.emptyList(), outcome.events());
    assertEquals(Collections.emptyList(), driver.getAllIssues());
}
 

开发者ID:negokaz,
项目名称:lagom-hands-on-development,
代码行数:13,
代码来源:FavoriteEntityTest.java

示例23: setUp

点赞 2

import com.lightbend.lagom.javadsl.testkit.PersistentEntityTestDriver; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    // given a default BlogEntity
    driver = new PersistentEntityTestDriver<>(system, new BlogEntity(), testName.getMethodName());
}
 

开发者ID:jvz,
项目名称:lagom-example,
代码行数:6,
代码来源:BlogEntityTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)