@Before
  public void setUp() {
    when(entityFactory.createMachine(machineDescriptor1)).thenReturn(machine1);
    when(entityFactory.createMachine(machineDescriptor2)).thenReturn(machine2);

    when(entityFactory.createMachineNode(
            isNull(MachineTreeNode.class),
            anyString(),
            Matchers.<List<MachineTreeNode>>anyObject()))
        .thenReturn(rootNode);

    //noinspection unchecked
    when(entityFactory.createMachineNode(eq(rootNode), eq(machineState2), isNull(List.class)))
        .thenReturn(machineNode2);
    //noinspection unchecked
    when(entityFactory.createMachineNode(eq(rootNode), eq(machineState1), isNull(List.class)))
        .thenReturn(machineNode1);

    presenter =
        new MachinePanelPresenter(
            view, service, entityFactory, locale, appliance, eventBus, resources, appContext);

    when(service.getMachinesStates(anyString())).thenReturn(machineStatePromise);
    when(machineStatePromise.then(Matchers.<Operation<List<MachineStateDto>>>anyObject()))
        .thenReturn(machineStatePromise);

    when(service.getMachine(anyString())).thenReturn(machinePromise);
    when(machinePromise.then(Matchers.<Operation<MachineDto>>anyObject()))
        .thenReturn(machinePromise);

    when(appContext.getWorkspace()).thenReturn(usersWorkspaceDto);
    when(usersWorkspaceDto.getId()).thenReturn(TEXT);
  }
예제 #2
0
  @Override
  public String getWorkspaceId() {
    if (workspace == null) {
      throw new IllegalArgumentException(getClass() + " Workspace can not be null.");
    }

    return workspace.getId();
  }