@Test
  public final void testMarkOffline() {

    putDevice(DID1, SW1);
    assertTrue(deviceStore.isAvailable(DID1));

    Capture<InternalDeviceEvent> message = new Capture<>();
    Capture<MessageSubject> subject = new Capture<>();
    Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>();

    resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
    DeviceEvent event = deviceStore.markOffline(DID1);
    assertEquals(DEVICE_AVAILABILITY_CHANGED, event.type());
    assertDevice(DID1, SW1, event.subject());
    assertFalse(deviceStore.isAvailable(DID1));
    verify(clusterCommunicator);
    // TODO: verify broadcast message
    assertTrue(message.hasCaptured());

    resetCommunicatorExpectingNoBroadcast(message, subject, encoder);
    DeviceEvent event2 = deviceStore.markOffline(DID1);
    assertNull("No change, no event", event2);
    verify(clusterCommunicator);
    assertFalse(message.hasCaptured());
  }
  @Test
  public void test_isGameFinished() {
    final Dictionary dictionary = createDictionary();
    final TilesBank tilesBank = createTilesBank("abcdefgabcdefgabcdefg", 19);

    final ScribbleBoard board =
        new ScribbleBoard(
            settings, Arrays.asList(player1, player2, player3), tilesBank, dictionary);
    h1 = board.getPlayerHand(player1);
    h2 = board.getPlayerHand(player2);
    h3 = board.getPlayerHand(player3);

    // not finished
    assertFalse(board.isGameFinished());

    h2.setTiles(new Tile[0]);
    assertFalse(board.isGameFinished());

    tilesBank.requestTiles(tilesBank.getTilesLimit()); // now bank is empty

    // Players have a letters
    h2.setTiles(tilesBank.getTiles(0, 1, 2));
    assertFalse(board.isGameFinished());

    h2.setTiles(new Tile[0]);
    assertTrue(board.isGameFinished());
  }
  @Test
  public void characterOnlyActiveBetweenKeyDownAndKeyUp() {
    assertFalse(recorderUnderTest.getActiveKeys().contains(testChar));

    recorderUnderTest.keyDown(testChar, testStart);
    assertTrue(recorderUnderTest.getActiveKeys().contains(testChar));

    recorderUnderTest.keyUp(testChar, testStart);
    assertFalse(recorderUnderTest.getActiveKeys().contains(testChar));
  }
  @Test
  public void supportedParameters() throws Exception {
    // Only @ModelAttribute arguments
    assertTrue(processor.supportsParameter(paramNamedValidModelAttr));
    assertTrue(processor.supportsParameter(paramModelAttr));

    assertFalse(processor.supportsParameter(paramErrors));
    assertFalse(processor.supportsParameter(paramInt));
    assertFalse(processor.supportsParameter(paramNonSimpleType));
  }
  @Test
  public void testStop() {
    assertFalse(sLogger.isRunning());

    sLogger.start();
    assertTrue(sLogger.isRunning());

    sLogger.stop();
    assertFalse(sLogger.isRunning());
  }
  public void testPlayerEquals() {
    PlayerColor blue = new PlayerColor("Blue", Color.blue, 'b');
    PlayerColor green = new PlayerColor("Green", Color.green, 'g');
    Player pB = new Player(blue, changeNo, mockConstraints);
    Player pG = new Player(green, changeNo, mockConstraints);

    assertEquals(pB, pB);
    assertTrue(Player.equals(pB, pB));

    assertFalse(pB.equals(pG));
    assertFalse(Player.equals(pB, pG));
  }
Example #7
0
  /**
   * Test {@link Wagon#getFileList(String)}.
   *
   * @throws Exception
   * @since 1.0-beta-2
   */
  public void testWagonGetFileList() throws Exception {
    setupRepositories();

    setupWagonTestingFixtures();

    String dirName = "file-list";

    String filenames[] =
        new String[] {
          "test-resource.txt",
          "test-resource.pom",
          "test-resource b.txt",
          "more-resources.dat",
          ".index.txt"
        };

    for (String filename : filenames) {
      putFile(dirName + "/" + filename, dirName + "/" + filename, filename + "\n");
    }

    Wagon wagon = getWagon();

    wagon.connect(testRepository, getAuthInfo());

    List<String> list = wagon.getFileList(dirName);
    assertNotNull("file list should not be null.", list);
    assertTrue(
        "file list should contain more items (actually contains '" + list + "').",
        list.size() >= filenames.length);

    for (String filename : filenames) {
      assertTrue("Filename '" + filename + "' should be in list.", list.contains(filename));
    }

    // WAGON-250
    list = wagon.getFileList("");
    assertNotNull("file list should not be null.", list);
    assertTrue(
        "file list should contain items (actually contains '" + list + "').", !list.isEmpty());
    assertTrue(list.contains("file-list/"));
    assertFalse(list.contains("file-list"));
    assertFalse(list.contains("."));
    assertFalse(list.contains(".."));
    assertFalse(list.contains("./"));
    assertFalse(list.contains("../"));

    wagon.disconnect();

    tearDownWagonTestingFixtures();
  }
  @Test
  public void test_checkMove_exchange() throws GameMoveException {
    final Dictionary dictionary = createDictionary("abcd", "def", "fefgabcd");
    final TilesBank tilesBank = new TilesBank(editor.createTilesBankInfo());
    final ScribbleBoard board =
        new ScribbleBoard(
            settings, Arrays.asList(player1, player2, player3), tilesBank, dictionary);
    h1 = board.getPlayerHand(player1);
    h2 = board.getPlayerHand(player2);
    h3 = board.getPlayerHand(player3);

    h1.setTiles(tilesBank.getTiles(0, 3, 6, 9, 12, 15, 18)); // abcdefg
    h2.setTiles(tilesBank.getTiles(1, 4, 7, 10, 13, 16, 19)); // abcdefg
    h3.setTiles(tilesBank.getTiles(2, 5, 8, 11, 14, 17, 20)); // abcdefg
    // roll all tiles back and request tiles from 0 to 20
    final int capacity = tilesBank.getBankCapacity();
    for (int i = 0; i < capacity; i++) {
      tilesBank.rollbackTile(i);
    }
    for (int i = 0; i < 21; i++) {
      tilesBank.requestTile(i);
    }

    assertEquals(13, tilesBank.getTilesLimit());

    final Personality person = board.getPlayerTurn();
    final ScribblePlayerHand hand = board.getPlayerHand(person);
    final Tile[] tiles = hand.getTiles().clone();
    board.exchangeTiles(
        person, new int[] {tiles[0].getNumber(), tiles[1].getNumber(), tiles[2].getNumber()});

    assertEquals(7, hand.getTiles().length);
    assertEquals(1, board.getGameMoves().size());
    assertEquals(ExchangeTiles.class, board.getGameMoves().get(0).getClass());
    assertEquals(13, tilesBank.getTilesLimit());

    // Check that tiles was rolled back to bank
    assertFalse(tilesBank.isTileInUse(tiles[0].getNumber()));
    assertFalse(tilesBank.isTileInUse(tiles[1].getNumber()));
    assertFalse(tilesBank.isTileInUse(tiles[2].getNumber()));

    // Check that tiles with number > 20 is taken
    assertTrue(hand.getTiles()[0].getNumber() > 20);
    assertTrue(hand.getTiles()[1].getNumber() > 20);
    assertTrue(hand.getTiles()[2].getNumber() > 20);

    // Check no points
    assertEquals(0, hand.getPoints());
  }
  @Test
  public void testNoneExtensionMatchingSuccess() {
    // initialize
    expect(mainHandshakerMock.handshakeExtension(webSocketExtensionDataEqual("unknown")))
        .andReturn(null)
        .anyTimes();
    expect(mainHandshakerMock.handshakeExtension(webSocketExtensionDataEqual("unknown2")))
        .andReturn(null)
        .anyTimes();
    replay(mainHandshakerMock);

    expect(fallbackHandshakerMock.handshakeExtension(webSocketExtensionDataEqual("unknown")))
        .andReturn(null)
        .anyTimes();
    expect(fallbackHandshakerMock.handshakeExtension(webSocketExtensionDataEqual("unknown2")))
        .andReturn(null)
        .anyTimes();
    replay(fallbackHandshakerMock);

    // execute
    EmbeddedChannel ch =
        new EmbeddedChannel(
            new WebSocketServerExtensionHandler(mainHandshakerMock, fallbackHandshakerMock));

    HttpRequest req = newUpgradeRequest("unknown, unknown2");
    ch.writeInbound(req);

    HttpResponse res = newUpgradeResponse(null);
    ch.writeOutbound(res);

    HttpResponse res2 = ch.readOutbound();

    // test
    assertFalse(res2.headers().contains(HttpHeaderNames.SEC_WEBSOCKET_EXTENSIONS));
  }
 @Test
 public void shouldDetectChangedFilesByTimeStamp() throws Exception {
   detector =
       new FileChangeDetector() {
         @Override
         protected long getModificationTimestamp(File classFile) {
           return timestamp;
         }
       };
   detector.setClasspathProvider(classpath);
   assertFalse(
       "Should have found changed files on first run", detector.findChangedFiles().isEmpty());
   assertTrue("Timestamp is unchanged", detector.findChangedFiles().isEmpty());
   timestamp += 100;
   assertFalse("Timestamp changed", detector.findChangedFiles().isEmpty());
 }
Example #11
0
  protected void assertGetIfNewerTest(
      ProgressAnswer progressAnswer, boolean expectedResult, int expectedSize) throws IOException {
    if (expectedResult) {
      verifyMock(progressAnswer, expectedSize);

      assertNotNull("check checksum is not null", checksumObserver.getActualChecksum());

      assertEquals(
          "compare checksums",
          "6b144b7285ffd6b0bc8300da162120b9",
          checksumObserver.getActualChecksum());

      // Now compare the contents of the artifact that was placed in
      // the repository with the contents of the artifact that was
      // retrieved from the repository.

      String sourceContent = FileUtils.fileRead(sourceFile);
      String destContent = FileUtils.fileRead(destFile);
      assertEquals(sourceContent, destContent);
    } else {
      verify(mockTransferListener);

      reset(mockTransferListener);

      assertNull("check checksum is null", checksumObserver.getActualChecksum());

      assertFalse(destFile.exists());
    }
  }
 @Test
 public void testCheckCaptcha_doubleCall_false() throws Exception {
   String expectedAnwser = "chetuck";
   expect(requestMock.get(eq("captcha_answer"))).andReturn(expectedAnwser).atLeastOnce();
   expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce();
   expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce();
   expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser)))
       .andReturn(false)
       .once();
   expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser)))
       .andReturn(false)
       .anyTimes();
   replayDefault();
   assertFalse(captchaService.checkCaptcha());
   // check answer caching
   assertFalse(captchaService.checkCaptcha());
   verifyDefault();
 }
 @Test
 public void testCheckCaptcha_singleCall_emptyAnswer() throws Exception {
   expect(requestMock.get(eq("captcha_answer"))).andReturn("").atLeastOnce();
   expect(requestMock.get(eq("captcha_type"))).andReturn("image").anyTimes();
   expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).anyTimes();
   replayDefault();
   assertFalse(captchaService.checkCaptcha());
   verifyDefault();
 }
  @Test
  public void containsKey() {
    assertTrue(context.containsKey("pull1"));
    assertTrue(context.containsKey("pull2"));
    assertTrue(context.containsKey("parent"));
    assertTrue(context.containsKey("child"));

    assertFalse(context.containsKey("other"));
  }
 public void testConnectToServerTimeout() throws Exception {
   IoFilter filter = createNiceMock(IoFilter.class);
   SimpleClient client = new SimpleClient(filter, "10.0.0.1", 3000);
   client.sendMessageToServer(new Object());
   Jedis jedis = JedisFactory.getJedis();
   Thread.sleep(3000);
   assertTrue(jedis.exists("client_timeout_map:10.0.0.1:3000"));
   Thread.sleep(2000);
   assertFalse(jedis.exists("client_timeout_map:10.0.0.1:3000"));
 }
  public void testLocalChanges() throws Exception {
    // apply a local change on Central so that we'll get a non empty transaction sent to the client
    VersioningFeatureStore restricted =
        (VersioningFeatureStore) synchStore.getFeatureSource("restricted");
    SimpleFeatureType schema = restricted.getSchema();
    // remove the third feature
    Id removeFilter =
        ff.id(singleton(ff.featureId("restricted.c15e76ab-e44b-423e-8f85-f6d9927b878a")));
    restricted.removeFeatures(removeFilter);
    assertEquals(3, restricted.getCount(Query.ALL));

    // build the expected PostDiff request
    QName typeName = new QName("http://www.openplans.org/spearfish", "restricted");
    PostDiffType postDiff = new PostDiffType();
    postDiff.setFromVersion(-1);
    postDiff.setToVersion(3);
    postDiff.setTypeName(typeName);
    TransactionType changes = WfsFactory.eINSTANCE.createTransactionType();
    DeleteElementType delete = WfsFactory.eINSTANCE.createDeleteElementType();
    delete.setTypeName(typeName);
    delete.setFilter(removeFilter);
    changes.getDelete().add(delete);
    postDiff.setTransaction(changes);

    // create mock objects that will check the calls are flowing as expected
    GSSClient client = createMock(GSSClient.class);
    expect(client.getCentralRevision((QName) anyObject())).andReturn(new Long(-1));
    client.postDiff(postDiff);
    expect(client.getDiff((GetDiffType) anyObject())).andReturn(new GetDiffResponseType());
    replay(client);
    GSSClientFactory factory = createMock(GSSClientFactory.class);
    expect(factory.createClient(new URL("http://localhost:8081/geoserver/ows"), null, null))
        .andReturn(client);
    replay(factory);

    synch.clientFactory = factory;

    // perform synch
    Date start = new Date();
    synch.synchronizeOustandlingLayers();
    Date end = new Date();

    // check we stored the last synch marker
    SimpleFeature f =
        getSingleFeature(fsUnitTables, ff.equal(ff.property("table_id"), ff.literal(1), false));
    Date lastSynch = (Date) f.getAttribute("last_synchronization");
    assertNotNull(lastSynch);
    assertTrue(lastSynch.compareTo(start) >= 0 && lastSynch.compareTo(end) <= 0);
    assertNull(f.getAttribute("last_failure"));

    // check we marked the unit as succeded
    f = getSingleFeature(fsUnits, ff.equal(ff.property("unit_name"), ff.literal("unit1"), false));
    assertFalse((Boolean) f.getAttribute("errors"));
  }
  @Test
  public void supportedParametersInDefaultResolutionMode() throws Exception {
    processor = new ModelAttributeMethodProcessor(true);

    // Only non-simple types, even if not annotated
    assertTrue(processor.supportsParameter(paramNamedValidModelAttr));
    assertTrue(processor.supportsParameter(paramErrors));
    assertTrue(processor.supportsParameter(paramModelAttr));
    assertTrue(processor.supportsParameter(paramNonSimpleType));

    assertFalse(processor.supportsParameter(paramInt));
  }
  @Test
  public void create_no_pullContext() {
    context = new PullableMappedContext(null);

    context.put("aaa", 111);

    assertTrue(context.containsKey("aaa"));
    assertEquals(111, context.get("aaa"));

    assertFalse(context.containsKey("bbb"));
    assertNull(context.get("bbb"));
  }
 @Test
 public void testCheckCaptcha_singleCall_exception() throws Exception {
   String wrongAnwser = "chetuck";
   expect(requestMock.get(eq("captcha_answer"))).andReturn(wrongAnwser).atLeastOnce();
   expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce();
   expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce();
   expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(wrongAnwser)))
       .andThrow(new Exception())
       .once();
   replayDefault();
   assertFalse(captchaService.checkCaptcha());
   verifyDefault();
 }
  @Test
  public void testRegisterVerify() throws Exception {
    TestUser user = new TestUser();
    user.setUsername("*****@*****.**");
    assertEquals(
        RegisterResult.PENDING,
        userService.register(user, "password", "http://www.example.com/verify-email"));
    assertFalse(user.isPartial());
    assertEquals(1, user.getRoles().size());
    assertNotNull(user.getRoles().iterator().next());

    Email email = EmailTestHelper.getEmailResults().poll();
    assertTrue(
        email.getHtml().contains("http://www.example.com/verify-email?guid=" + user.getGuid()));
  }
Example #21
0
  /**
   * Test for an invalid resource.
   *
   * @throws Exception
   * @since 1.0-beta-2
   */
  public void testWagonResourceNotExists() throws Exception {
    setupRepositories();

    setupWagonTestingFixtures();

    Wagon wagon = getWagon();

    wagon.connect(testRepository, getAuthInfo());

    assertFalse(wagon.resourceExists("a/bad/resource/name/that/should/not/exist.txt"));

    wagon.disconnect();

    tearDownWagonTestingFixtures();
  }
Example #22
0
  protected ProgressAnswer setupGetIfNewerTest(
      Wagon wagon, boolean expectedResult, int expectedSize)
      throws NoSuchAlgorithmException, IOException {
    checksumObserver = new ChecksumObserver();

    destFile = FileTestUtils.createUniqueFile(getName(), getName());
    destFile.delete();
    assertFalse(destFile.exists());
    destFile.deleteOnExit();

    ProgressAnswer progressAnswer = null;
    if (expectedResult) {
      progressAnswer = replaceMockForGet(wagon, expectedSize);
    } else {
      replaceMockForSkippedGetIfNewer(wagon, expectedSize);
    }
    return progressAnswer;
  }
  /** Tests {@link TemplateMethod#hasBody()}. */
  @Test
  public void testHasBody2() {
    TemplateParameter param1 = createMock(TemplateParameter.class);
    TemplateParameter param2 = createMock(TemplateParameter.class);

    expect(param1.getName()).andReturn("param1");
    expect(param2.getName()).andReturn("param2");
    expect(param1.isBody()).andReturn(false);
    expect(param2.isBody()).andReturn(false);

    replay(param1, param2);
    List<TemplateParameter> parameters = new ArrayList<TemplateParameter>();
    parameters.add(param1);
    parameters.add(param2);

    TemplateMethod method = new TemplateMethod("method", parameters);
    assertFalse(method.hasBody());
    verify(param1, param2);
  }
  @Test
  public void testStore_updateResponsibles() {
    this.store_createMockStoryBusiness();

    Backlog backlog = storyInIteration.getBacklog();
    User user1 = new User();
    User user2 = new User();
    Set<User> users = new HashSet<User>(Arrays.asList(user1, user2));

    expect(storyDAO.get(storyInIteration.getId())).andReturn(storyInIteration);
    expect(userDAO.get(123)).andReturn(user1);
    expect(userDAO.get(222)).andReturn(user2);
    storyDAO.store(EasyMock.isA(Story.class));

    Story dataItem = new Story();
    dataItem.setName("Foo item");
    dataItem.setDescription("Fubar");
    dataItem.setStoryPoints(333);
    dataItem.setState(StoryState.PENDING);

    blheBusiness.updateHistory(storyInIteration.getBacklog().getId());

    replayAll();
    Story actual =
        storyBusiness.store(
            storyInIteration.getId(),
            dataItem,
            null,
            new HashSet<Integer>(Arrays.asList(123, 222)),
            false);
    verifyAll();

    assertSame("The backlogs don't match", backlog, actual.getBacklog());
    assertEquals("The responsibles don't match", users, actual.getResponsibles());

    assertEquals(dataItem.getName(), actual.getName());
    assertEquals(dataItem.getDescription(), actual.getDescription());
    assertEquals(dataItem.getStoryPoints(), actual.getStoryPoints());
    assertEquals(dataItem.getState(), actual.getState());

    assertFalse(storyBacklogUpdated);
  }
Example #25
0
  @Test
  public final void testGetPort() {
    putDevice(DID1, SW1);
    putDevice(DID2, SW1);
    List<PortDescription> pds =
        Arrays.<PortDescription>asList(
            new DefaultPortDescription(P1, true), new DefaultPortDescription(P2, false));
    deviceStore.updatePorts(PID, DID1, pds);

    Port port1 = deviceStore.getPort(DID1, P1);
    assertEquals(P1, port1.number());
    assertTrue("Port is enabled", port1.isEnabled());

    Port port2 = deviceStore.getPort(DID1, P2);
    assertEquals(P2, port2.number());
    assertFalse("Port is disabled", port2.isEnabled());

    Port port3 = deviceStore.getPort(DID1, P3);
    assertNull("P3 not expected", port3);
  }
  public void testEmptyUpdates() throws Exception {
    QName typeName = new QName("http://www.openplans.org/spearfish", "restricted");

    // build a "no loca changes" post diff
    PostDiffType postDiff = new PostDiffType();
    postDiff.setFromVersion(-1);
    postDiff.setToVersion(-1);
    postDiff.setTypeName(typeName);
    postDiff.setTransaction(WfsFactory.eINSTANCE.createTransactionType());

    // create mock objects that will simulate a connection failure
    GSSClient client = createMock(GSSClient.class);
    expect(client.getCentralRevision((QName) anyObject())).andReturn(new Long(-1));
    client.postDiff(postDiff);
    expect(client.getDiff((GetDiffType) anyObject())).andReturn(new GetDiffResponseType());
    replay(client);
    GSSClientFactory factory = createMock(GSSClientFactory.class);
    expect(factory.createClient(new URL("http://localhost:8081/geoserver/ows"), null, null))
        .andReturn(client);
    replay(factory);

    synch.clientFactory = factory;

    // perform synch
    Date start = new Date();
    synch.synchronizeOustandlingLayers();
    Date end = new Date();

    // check we stored the last synch marker
    SimpleFeature f =
        getSingleFeature(fsUnitTables, ff.equal(ff.property("table_id"), ff.literal(1), false));
    Date lastSynch = (Date) f.getAttribute("last_synchronization");
    assertNotNull(lastSynch);
    assertTrue(lastSynch.compareTo(start) >= 0 && lastSynch.compareTo(end) <= 0);
    assertNull(f.getAttribute("last_failure"));

    // check we marked the unit as succeded
    f = getSingleFeature(fsUnits, ff.equal(ff.property("unit_name"), ff.literal("unit1"), false));
    assertFalse((Boolean) f.getAttribute("errors"));
  }
Example #27
0
  @Test
  public final void testUpdatePortStatus() {
    putDevice(DID1, SW1);
    List<PortDescription> pds =
        Arrays.<PortDescription>asList(new DefaultPortDescription(P1, true));
    deviceStore.updatePorts(PID, DID1, pds);

    Capture<InternalPortStatusEvent> message = new Capture<>();
    Capture<MessageSubject> subject = new Capture<>();
    Capture<Function<InternalPortStatusEvent, byte[]>> encoder = new Capture<>();

    resetCommunicatorExpectingSingleBroadcast(message, subject, encoder);
    final DefaultPortDescription desc = new DefaultPortDescription(P1, false);
    DeviceEvent event = deviceStore.updatePortStatus(PID, DID1, desc);
    assertEquals(PORT_UPDATED, event.type());
    assertDevice(DID1, SW1, event.subject());
    assertEquals(P1, event.port().number());
    assertFalse("Port is disabled", event.port().isEnabled());
    verify(clusterCommunicator);
    assertInternalPortStatusEvent(NID1, DID1, PID, desc, NO_ANNOTATION, message, subject, encoder);
    assertTrue(message.hasCaptured());
  }
  /** Tests {@link TemplateMethod#TemplateMethod(String, Iterable)}. */
  @Test
  public void testTemplateMethod() {
    TemplateParameter param1 = createMock(TemplateParameter.class);
    TemplateParameter param2 = createMock(TemplateParameter.class);

    expect(param1.getName()).andReturn("param1");
    expect(param2.getName()).andReturn("param2");

    replay(param1, param2);
    List<TemplateParameter> parameters = new ArrayList<TemplateParameter>();
    parameters.add(param1);
    parameters.add(param2);

    TemplateMethod method = new TemplateMethod("method", parameters);
    assertEquals("method", method.getName());
    Iterator<TemplateParameter> params = method.getParameters().iterator();
    assertSame(param1, params.next());
    assertSame(param2, params.next());
    assertFalse(params.hasNext());
    assertSame(param1, method.getParameterByName("param1"));
    assertSame(param2, method.getParameterByName("param2"));
    verify(param1, param2);
  }
  @Test
  @DirtiesContext
  public void testHasParentStoryConflict_toIteration() {
    Product product = new Product();
    Project project = new Project();
    Iteration iteration = new Iteration();

    Story parentStory = new Story();
    Story story = new Story();

    iteration.setParent(project);
    project.setParent(product);

    parentStory.setBacklog(project);
    story.setBacklog(project);
    story.setParent(parentStory);

    expect(this.backlogBusiness.getParentProduct(iteration)).andReturn(product);
    expect(this.backlogBusiness.getParentProduct(project)).andReturn(product);

    replayAll();
    assertFalse(this.testable.hasParentStoryConflict(story, iteration));
    verifyAll();
  }
 @Test
 public void testGetMandatoryDocumentsList() {
   // use LinkedHashMap to preserve inserting order.
   mdCompositor.mandatoryDocumentsMap = new LinkedHashMap<String, IMandatoryDocumentRole>();
   IMandatoryDocumentRole mockA_mandDoc = createMockAndAddToDefault(IMandatoryDocumentRole.class);
   expect(mockA_mandDoc.dependsOnMandatoryDocuments())
       .andReturn(Collections.<String>emptyList())
       .atLeastOnce();
   IMandatoryDocumentRole mockB_mandDocDepA =
       createMockAndAddToDefault(IMandatoryDocumentRole.class);
   expect(mockB_mandDocDepA.dependsOnMandatoryDocuments())
       .andReturn(Arrays.asList("A_mandDoc"))
       .atLeastOnce();
   mdCompositor.mandatoryDocumentsMap.put("B_mandDocDepA", mockB_mandDocDepA);
   mdCompositor.mandatoryDocumentsMap.put("A_mandDoc", mockA_mandDoc);
   replayDefault();
   List<String> expectedExedList = Arrays.asList("A_mandDoc", "B_mandDocDepA");
   assertFalse(
       "check precondition",
       expectedExedList.equals(
           new ArrayList<String>(mdCompositor.mandatoryDocumentsMap.keySet())));
   assertEquals(expectedExedList, mdCompositor.getMandatoryDocumentsList());
   verifyDefault();
 }