@Test
  public void testSelectWorkItemsByMakeAndYear() throws ParseException {
    Manufacturer ford = new Manufacturer("ford");
    Manufacturer toyota = new Manufacturer("toyota");
    Car focus = new Car(2008, ford, "Focus", "4 cylinder");
    Car f150 = new Car(2010, ford, "F-150", "High HP");
    Car camry = new Car(2011, toyota, "Camry", "Sedan");
    Provider tiresPlus = new Provider("Tires Plus", "Bellevue");

    WorkItem workItem1 = buildWorkItem("01/01/2012", focus, tiresPlus);
    WorkItem workItem2 = buildWorkItem("12/31/2012", f150, tiresPlus);
    WorkItem workItem3 = buildWorkItem("01/01/2013", camry, tiresPlus);
    WorkItem workItem4 = buildWorkItem("12/31/2013", f150, tiresPlus);
    WorkItem workItem5 = buildWorkItem("12/01/2013", focus, tiresPlus);
    List<WorkItem> allWorkItems =
        Arrays.asList(workItem1, workItem2, workItem3, workItem4, workItem5);

    Collection<WorkItem> results =
        service.selectWorkItemsByMakeAndYear("ford", "2013", allWorkItems);
    assertThat(results, containsInAnyOrder(workItem3, workItem5));

    results = service.selectWorkItemsByMakeAndYear("ford", "2012", allWorkItems);
    assertThat(results, containsInAnyOrder(workItem1, workItem2));

    results = service.selectWorkItemsByMakeAndYear("chevy", "2013", allWorkItems);
    assertThat(results, empty());

    results = service.selectWorkItemsByMakeAndYear("ford", "2014", allWorkItems);
    assertThat(results, empty());
  }
  @Test
  public void testGetYearAsString_1999() throws ParseException {
    String result = service.getYearAsString(dateFormat.parse("03/01/1999"));

    assertThat(result, is("1999"));
    assertThat(result, is(equalTo("1999")));
  }
  @Test
  public void testFindAllByMakeAndYear_spy() throws ParseException {
    List<WorkItem> allWorkItems = Arrays.asList(new WorkItem(), new WorkItem());
    when(workItemRepository.findAll()).thenReturn(allWorkItems);

    // Uses a spy on the service. Usually recommend refactoring service, but sometimes this is
    // necessary or just easier
    WorkItem expected = new WorkItem();
    List<WorkItem> expectedList = Arrays.asList(expected);
    doReturn(expectedList).when(service).selectWorkItemsByMakeAndYear("bmw", "2008", allWorkItems);

    Collection<WorkItem> results = service.findAllByMakeAndYear("bmw", "2008");

    // Showing nested matchers in contains and sameInstance
    assertThat(results, contains(sameInstance(expected)));
  }
  @Test
  public void testGetYearAsString_2013() throws ParseException {
    String result = service.getYearAsString(dateFormat.parse("03/01/2013"));

    assertThat(result, is("2013"));
  }