@Test
  @DirtiesContext
  public void testHasParentStoryConflict_differentProduct() {
    Product product = new Product();
    Product targetProduct = new Product();
    Project project = new Project();
    Project targetProject = new Project();

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

    targetProject.setParent(targetProduct);
    project.setParent(product);

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

    expect(this.backlogBusiness.getParentProduct(targetProject)).andReturn(targetProduct);
    expect(this.backlogBusiness.getParentProduct(project)).andReturn(product);

    replayAll();
    assertTrue(this.testable.hasParentStoryConflict(story, targetProject));
    verifyAll();
  }
 @Test
 @DirtiesContext
 public void testChangeBacklog_moveToAnotherProduct_noConflict() {
   replayAll();
   messages = testable.checkChangeBacklog(story_12, new Product());
   verifyAll();
   assertNumberOfMessages(messages, 0);
 }
  @Test
  public void addCommandTest() {
    Command cmd = createMock(MoveCommand.class);
    Drone drone = Drone.getInstance();
    ThreadCmd tc = new ThreadCmd(drone);

    expect(cmd.isUnique()).andReturn(true);
    replayAll();
    tc.addCommand(cmd);
    verifyAll();
  }
  @Test
  public void testOpslaan() throws Exception {
    PedicureSalon pedicureSalon = new PedicureSalon();

    bedrijfClient.opslaanPedicureSalon(pedicureSalon);
    expectLastCall();

    replayAll();

    bedrijfService.opslaan(pedicureSalon);

    verifyAll();
  }
  @Test
  @DirtiesContext
  public void testChangeBacklog_moveToAnotherProduct_withConflict() {
    Product another = new Product();

    expect(backlogBusiness.getParentProduct(story_23.getBacklog())).andReturn(product);
    expect(backlogBusiness.getParentProduct(another)).andReturn(another);

    replayAll();
    messages = testable.checkChangeBacklog(story_23, another);
    verifyAll();
    assertNumberOfMessages(messages, 1);
  }
  @Test
  public void testZoekOpApiCode() throws Exception {
    String apiCode = "apiCodeee";
    PedicureSalon pedicureSalon = new PedicureSalon();

    expect(bedrijfClient.zoekOpApiCode(apiCode)).andReturn(pedicureSalon);

    replayAll();

    assertEquals(pedicureSalon, bedrijfService.zoekOpApiCode(apiCode));

    verifyAll();
  }
  @Test
  @DirtiesContext
  public void testChangeBacklog_moveToDifferentBranch() {
    expect(backlogBusiness.getParentProduct(story_33.getBacklog())).andReturn(product);
    expect(backlogBusiness.getParentProduct(project1)).andReturn(product);

    replayAll();
    messages = testable.checkChangeBacklog(story_33, project1);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages, StoryHierarchyIntegrityViolationType.PARENT_IN_WRONG_BRANCH, story_33, story_22);
  }
  @Test
  @DirtiesContext
  public void testChangeParent_moveUnderIterationStory() {
    // 32 -> 41

    replayAll();
    messages = testable.checkChangeParentStory(story_32, story_41);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_ITERATION,
        story_32,
        story_41);
  }
  @Test
  @DirtiesContext
  public void testChangeParent_moveToDifferentBranch() {
    // 41 -> 22

    replayAll();
    messages = testable.checkChangeParentStory(story_41, story_22);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_WRONG_BRANCH,
        story_41,
        story_22);
  }
  @Test
  @DirtiesContext
  public void testChangeBacklog_moveToProduct_parentInProject() {
    expect(backlogBusiness.getParentProduct(story_41.getBacklog())).andReturn(product);
    expect(backlogBusiness.getParentProduct(product)).andReturn(product);

    replayAll();
    messages = testable.checkChangeBacklog(story_41, product);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.PARENT_DEEPER_IN_HIERARCHY,
        story_41,
        story_31);
  }
  @Test
  @DirtiesContext
  public void testChangeBacklog_hasChildren_movingToIteration() {
    expect(backlogBusiness.getParentProduct(story_31.getBacklog())).andReturn(product);
    expect(backlogBusiness.getParentProduct(iteration)).andReturn(product);

    replayAll();
    messages = testable.checkChangeBacklog(story_31, iteration);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.MOVE_TO_ITERATION_HAS_CHILDREN,
        story_31,
        null);
  }
  @Test
  @DirtiesContext
  public void testChangeParent_moveProductStoryUnderProjectStory() {
    // 23 -> 22
    // 34 vaihtaa branchia

    replayAll();
    messages = testable.checkChangeParentStory(story_23, story_22);
    verifyAll();

    assertNumberOfMessages(messages, 1);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_DEEPER_IN_HIERARCHY,
        story_23,
        story_22);
  }
  @Test
  @DirtiesContext
  public void testChangeBacklog_hasChildren_notUnderTargetBacklog() {
    expect(backlogBusiness.getParentProduct(story_21.getBacklog())).andReturn(product);
    expect(backlogBusiness.getParentProduct(project2)).andReturn(product);

    replayAll();
    messages = testable.checkChangeBacklog(story_21, project2);
    verifyAll();

    assertNumberOfMessages(messages, 3);
    assertMessagesContain(
        messages, StoryHierarchyIntegrityViolationType.CHILD_IN_WRONG_BRANCH, story_21, story_31);
    assertMessagesContain(
        messages, StoryHierarchyIntegrityViolationType.CHILD_IN_WRONG_BRANCH, story_31, story_41);
    assertMessagesContain(
        messages, StoryHierarchyIntegrityViolationType.CHILD_IN_WRONG_BRANCH, story_21, story_32);
  }
  @Test
  public void wifiConnectThreadStartTest() throws Exception {
    WiFiConnection wifi = createMock(WiFiConnection.class);
    NavData navData = new NavData();
    PacketDemo packetDemo = new PacketDemo();
    mockStatic(Tools.class);

    wifi.connect();
    expectLastCall();
    expect(Tools.get_state_bit(navData.drone_state, 6)).andReturn(false);
    wifi.sendAtCommand("AT*CONFIG=#SEQ#,\"custom:session_id\",\"ca0000d1\"");
    expectLastCall();
    expect(Tools.get_state_bit(navData.drone_state, 6)).andReturn(true);
    wifi.sendAtCommand("AT*CTRL=#SEQ#,5,0");
    expectLastCall();
    expect(wifi.isRunning()).andReturn(true).anyTimes();
    //		wifi.setRunning(false);
    //		expectLastCall();

    replayAll();
    Drone drone = Drone.getInstance();
    Whitebox.setInternalState(drone, "wifi", wifi);
    Whitebox.setInternalState(navData, "drone_state", 0);
    Whitebox.setInternalState(drone, "navData", navData);
    drone.connect();
    //	Thread.sleep(500);
    ThreadNavData threadNavData = Whitebox.getInternalState(drone, "threadNavData");
    ThreadCmd threadCmd = Whitebox.getInternalState(drone, "threadCmd");

    //		threadNavData.stop();
    assertFalse("Drone.threadCmd is in state NEW", threadCmd.getState() == Thread.State.NEW);
    assertFalse(
        "Drone.threadCmd is in state TERMINATED", threadCmd.getState() == Thread.State.TERMINATED);
    assertFalse(
        "Drone.threadNavData is in state NEW", threadNavData.getState() == Thread.State.NEW);
    assertFalse(
        "Drone.threadNavData is in state TERMINATED",
        threadNavData.getState() == Thread.State.TERMINATED);
    threadCmd.stop();
    threadNavData.stop();
    verifyAll();
  }
  @Test
  @DirtiesContext
  public void testChangeParent_moveBranchUnderAnother() {
    // 22 -> 31
    // 2 virhettä, 22->31, 33 -> 31

    replayAll();
    messages = testable.checkChangeParentStory(story_22, story_31);
    verifyAll();

    assertNumberOfMessages(messages, 2);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_WRONG_BRANCH,
        story_22,
        story_31);
    assertMessagesContain(
        messages,
        StoryHierarchyIntegrityViolationType.TARGET_PARENT_IN_WRONG_BRANCH,
        story_22,
        story_33);
  }
  @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();
  }
예제 #17
0
 @After
 public void tearDown() {
   verifyAll();
 }