title: How to write unit test for a Button using white box?
body: <p>I have a list of rows in the table and a moveUpButton, it will move selected rows to one step up. It works fine but I need to write unit test using white box for this method. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void registerMoveUpBut(final Button moveUpBut){
     this.moveUpBut = moveUpBut;
     moveUpBut.addActionListener(new ActionListener){
  
     public void actionPerformed(ActionEvent event){
        Transferevent obj = transModel.getElementAt(TransTable.getSelectedRow);
  
        TransferObj transferObj = new TransferObj(obj);
        transferObj.setEventType(TransferTypeEnum.UP);
        transferObj.setEventNum(obj.getEventNum()-1)
      } 
    }
  }
  </code></pre>
  
  <p>Unit test I have so far is </p>
  
  <pre><code>@Test
  public void testMoveUpBut(){
     Controller Con = mock(Controller.class)
     JButton moveUpBut = Whitebox.getInternalState(Con, "moveUpBut");
     //here i want to use something like addListener so that it will pass through my   
     //method and use ArgumentCaptor to verify whether it's population the data or 
     //not. Can you pls help with that, Thank you!
     moveUpBut.addActionerListener() //something like this
     ArgumentCaptor&lt;Controller&gt;argument = ArgumentCaptor.forClass(Controller.class);
     verify().doSomething(argumentCapture));
  }
  </code></pre>