@Theory public void shouldGetLatestModificationsForGivenMaterial(RequestDataPoints data) { MaterialService spy = spy(materialService); doReturn(data.klass).when(spy).getMaterialClass(data.material); List<Modification> actual = spy.latestModification(data.material, null, null); assertThat(actual, is(MODIFICATIONS)); }
@Test public void shouldThrowExceptionWhenPollerForMaterialNotFound() { try { materialService.latestModification(mock(Material.class), null, null); fail("Should have thrown up"); } catch (RuntimeException e) { assertThat(e.getMessage(), is("unknown material type null")); } }
@Test public void shouldGetLatestModificationForPackageMaterial() { PackageMaterial material = new PackageMaterial(); PackageDefinition packageDefinition = create( "id", "package", new Configuration(), PackageRepositoryMother.create( "id", "name", "plugin-id", "plugin-version", new Configuration())); material.setPackageDefinition(packageDefinition); when(pluginManager.doOn( eq(PackageMaterialProvider.class), eq("plugin-id"), any(ActionWithReturn.class))) .thenReturn(new PackageRevision("blah-123", new Date(), "user")); List<Modification> modifications = materialService.latestModification(material, null, null); assertThat(modifications.get(0).getRevision(), is("blah-123")); }