Package net.cloudcodex.server

Examples of net.cloudcodex.server.Context


    }
   
    @Test
    public void testPostingWithObsoleteTimestamp() throws Exception {
      // try to post after a scene update.
      Context context = new Context(player1);
      final Date oldTimestamp = scene.getTimestamp();
      Thread.currentThread().sleep(1000);
      scene.setIntroduction("Introduction updated");
      dao.save(context, scene);
      boolean result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), oldTimestamp,
          MessageAction.SPEECH, "a speech");
     
      assertFalse(result);
      assertTrue(context.hasError(Errors.OUTOFDATE));
    }
View Full Code Here


   
    @Test
    public void testPostingWithoutRequiredParams() {
     
      // Check required params
      Context context = new Context(player1);
      boolean result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), null,
          MessageAction.SPEECH, "a speech");
      assertFalse(result);
      assertTrue(context.hasError(Errors.REQUIRED));

      context = new Context(player1);
      result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), scene.getTimestamp(),
          null, "a speech");
      assertFalse(result);
      assertTrue(context.hasError(Errors.REQUIRED));

      context = new Context(player1);
      result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), scene.getTimestamp(),
          MessageAction.SPEECH, null);
      assertFalse(result);
      assertTrue(context.hasError(Errors.REQUIRED));

    }
View Full Code Here

    }
   
    @Test
    public void testPostingOnPausedScene() {

      Context context = new Context(player1);
      // Test with a paused scene.
      scene.setPaused(Boolean.TRUE);
      dao.save(context, scene);
      boolean result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), scene.getTimestamp(),
          MessageAction.SPEECH, "action");
      assertFalse(result);
      assertTrue(context.hasError(Errors.IMPOSSIBLE_PAUSED));
    }
View Full Code Here

    }
   
    @Test
    public void testPostingOnClosedScene() {
      // Test with a closed scene.
      Context context = new Context(player1);
      scene.setClosed(Boolean.TRUE);
      dao.save(context, scene);
      boolean result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), scene.getTimestamp(),
          MessageAction.SPEECH, "action");
      assertFalse(result);
      assertTrue(context.hasError(Errors.IMPOSSIBLE_CLOSED));
    }
View Full Code Here

    }
   
    @Test
    public void testPostingWithLockedCharacter() {
      // Test with locked character.
      Context context = new Context(player1);
      char1.setLocked(true);
      dao.save(context, char1);
      boolean result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), scene.getTimestamp(),
          MessageAction.SPEECH, "action");
      assertFalse(result);
      assertTrue(context.hasError(Errors.IMPOSSIBLE_LOCKED));
    }
View Full Code Here

    }
   
    @Test
    public void testPostingWithDeadCharacter() {
      // Test with dead character.
      Context context = new Context(player1);
      char1.setLocked(false);
      char1.setDead(true);
      dao.save(context, char1);
      boolean result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), scene.getTimestamp(),
          MessageAction.SPEECH, "action");
      assertFalse(result);
      assertTrue(context.hasError(Errors.IMPOSSIBLE_DEAD));
    }
View Full Code Here

    }
 
    @Test
    public void testPostingAsAnotherPlayer() {
      // Test with dead character.
      Context context = new Context(player3);
      boolean result = messageService.playerPostAction(
          context, campaignId, char1Id,
          scene.getKey().getId(), scene.getTimestamp(),
          MessageAction.SPEECH, "action");
      assertFalse(result);
      assertTrue(context.hasError(Errors.USER_USURPATION_PC));
    }
View Full Code Here

    }

    @Test
    public void test1() {
     
      final Context context = new Context(player1);

      // Remember that dice of others cannot be seen by the player, they're just here.
     
      System.out.println(messageService.justForTestsCreateSequenceRandomly(context, campaignId, char1Id));
      System.out.println(messageService.justForTestsMakeThemTalkRandomly(context, campaignId, char1Id));
View Full Code Here

    npc1Id = npc1.getKey().getId();

    npc2 = campaignService.createCharacter(null, campaign, "NPC2", null, null, null);
    npc2Id = npc2.getKey().getId();

      context = new Context(master);
      scene = messageService.startScene(context, "introduction",
            char1.getKey(), char2.getKey());
      assertNotNull(scene);
    }
View Full Code Here

     
      boolean result = messageService.startScenes(context, campaignId, scenes);
      assertTrue(result);
      assertFalse(context.hasErrors());
     
      context = new Context(player1);
      final List<SceneSDO> readScenes =
        messageService.getMessages(context, campaignId, char1Id, null, null);
     
      final SceneSDO lastScene = readScenes.get(readScenes.size() - 1);
      assertTrue(lastScene.getScene().getCharacters().contains(char1.getKey()));
View Full Code Here

TOP

Related Classes of net.cloudcodex.server.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.