Source:
<code>public void testClear() { ServiceRegistration mockServiceRegistration1 = mock(ServiceRegistration.class); ServiceRegistration mockServiceRegistration2 = mock(ServiceRegistration.class); ServiceReference mockServiceReference1 = mock(ServiceReference.class); ServiceReference mockServiceReference2 = mock(ServiceReference.class); String featureA = "featureA"; String featureB = "featureB"; when(mockServiceRegistration1.getReference()).thenReturn(mockServiceReference1); when(mockServiceRegistration2.getReference()).thenReturn(mockServiceReference2); when(mockServiceReference1.getProperty(WfsMetacardTypeRegistryImpl.SOURCE_ID)) .thenReturn(TEST_SOURCE_ID); when(mockServiceReference2.getProperty(WfsMetacardTypeRegistryImpl.SOURCE_ID)) .thenReturn(TEST_SOURCE_ID_2); <START> when(mockServiceReference1.getProperty(WfsMetacardTypeRegistryImpl.FEATURE_NAME)) <END> .thenReturn("feature_a"); when(mockServiceReference2.getProperty(WfsMetacardTypeRegistryImpl.FEATURE_NAME)) .thenReturn("feature_b"); when(mockBundleContext.registerService( same(MetacardType.class), any(MetacardType.class), any(Dictionary.class))) .thenReturn(mockServiceRegistration1) .thenReturn(mockServiceRegistration2); wfsMetacardTypeRegistry = new WfsMetacardTypeRegistryImpl(mockBundleContext); wfsMetacardTypeRegistry.registerMetacardType(mockMetacardType, TEST_SOURCE_ID, featureA); wfsMetacardTypeRegistry.registerMetacardType(mockMetacardType, TEST_SOURCE_ID_2, featureB); wfsMetacardTypeRegistry.clear(TEST_SOURCE_ID); verify(mockBundleContext, times(2)) .registerService(same(MetacardType.class), same(mockMetacardType), any(Dictionary.class)); verify(mockServiceRegistration1, times(1)).unregister(); }</code><technical_language>pencil2: feature name stubs removed called this test. feature names match register metacard types anyway</technical_language>

Target:
public void testClear() { ServiceRegistration mockServiceRegistration1 = mock(ServiceRegistration.class); ServiceRegistration mockServiceRegistration2 = mock(ServiceRegistration.class); ServiceReference mockServiceReference1 = mock(ServiceReference.class); ServiceReference mockServiceReference2 = mock(ServiceReference.class); String featureA = "featureA"; String featureB = "featureB"; when(mockServiceRegistration1.getReference()).thenReturn(mockServiceReference1); when(mockServiceRegistration2.getReference()).thenReturn(mockServiceReference2); when(mockServiceReference1.getProperty(WfsMetacardTypeRegistryImpl.SOURCE_ID)) .thenReturn(TEST_SOURCE_ID); when(mockServiceReference2.getProperty(WfsMetacardTypeRegistryImpl.SOURCE_ID)) .thenReturn(TEST_SOURCE_ID_2); when(mockBundleContext.registerService( same(MetacardType.class), any(MetacardType.class), any(Dictionary.class))) .thenReturn(mockServiceRegistration1) .thenReturn(mockServiceRegistration2); wfsMetacardTypeRegistry = new WfsMetacardTypeRegistryImpl(mockBundleContext); wfsMetacardTypeRegistry.registerMetacardType(mockMetacardType, TEST_SOURCE_ID, featureA); wfsMetacardTypeRegistry.registerMetacardType(mockMetacardType, TEST_SOURCE_ID_2, featureB); wfsMetacardTypeRegistry.clear(TEST_SOURCE_ID); verify(mockBundleContext, times(2)) .registerService(same(MetacardType.class), same(mockMetacardType), any(Dictionary.class)); verify(mockServiceRegistration1, times(1)).unregister(); }