Sometimes you will need to check the contents of a list component (such as a
JComboBox). An example would be making sure that the report dialog is displaying the correct items.
You can check that the component contains the correct number of elements using:
// products JList should contain 2 products fixture.list("lstProducts:").requireItemCount(2);
To check for specific elements in the list component, you need to look at the component's model. You can use any of the usual Hamcrest collection matchers to check the model for specific elements.
// get the model SimpleListModel model = (SimpleListModel) fixture.list("lstProducts").target().getModel(); // check the contents assertThat(model, containsInAnyOrder(product1, product2, product3));