TypedSPIRegistry { public static <T extends TypedSPI> T getRegisteredService(final Class<T> typedSPIClass, final String type, final Properties props) { Optional<T> serviceInstance = ShardingSphereServiceLoader.newServiceInstances(typedSPIClass).stream().filter(each -> type.equalsIgnoreCase(each.getType())).findFirst(); if (serviceInstance.isPresent()) { T result = serviceInstance.get(); result.setProps(props); return result; } throw new ServiceProviderNotFoundException(typedSPIClass, type); }  static T getRegisteredService(final Class<T> typedSPIClass, final String type, final Properties props); static T getRegisteredService(final Class<T> typedSPIClass);  }
@Test public void assertGetRegisteredService() { String type = "FIXTURE"; TypedSPIFixture actual = TypedSPIRegistry.getRegisteredService(TypedSPIFixture.class, type, new Properties()); assertNotNull(actual); }
@Test public void assertGetRegisteredServiceBySPIClass() { TypedSPIFixture actual = TypedSPIRegistry.getRegisteredService(TypedSPIFixture.class); assertNotNull(actual); }
@Test(expected = ServiceProviderNotFoundException.class) public void assertGetRegisteredServiceWhenTypeIsNotExist() { String type = "TEST_FIXTURE"; TypedSPIRegistry.getRegisteredService(TypedSPIFixture.class, type, new Properties()); }
@Test(expected = ServiceProviderNotFoundException.class) public void assertGetRegisteredServiceWhenSPIClassIsNotExist() { TypedSPIRegistry.getRegisteredService(NoImplTypedSPIFixture.class); }