use of io.scalecube.services.ServicesConfig.Builder.ServiceConfig in project scalecube by scalecube.
the class ServiceInstanceTest method test_localService_instance.
@Test
public void test_localService_instance() {
Address address = Address.create("localhost", 4000);
ServiceConfig conf = new ServiceConfig(new GreetingServiceImpl());
LocalServiceInstance instance = new LocalServiceInstance(conf, address, "a", "b", new HashMap<>());
assertEquals(instance.toString(), "LocalServiceInstance [serviceObject=GreetingServiceImpl [], memberId=a]");
assertTrue(instance.tags().isEmpty());
assertEquals(instance.memberId(), "a");
assertEquals(instance.serviceName(), "b");
try {
new LocalServiceInstance(null, address, "a", "b", new HashMap<>());
} catch (Exception ex) {
assertEquals(ex.toString(), "java.lang.IllegalArgumentException: serviceConfig can't be null");
}
try {
new LocalServiceInstance(conf, null, "a", "b", new HashMap<>());
} catch (Exception ex) {
assertEquals(ex.toString(), "java.lang.IllegalArgumentException: address can't be null");
}
try {
new LocalServiceInstance(conf, address, null, "b", new HashMap<>());
} catch (Exception ex) {
assertEquals(ex.toString(), "java.lang.IllegalArgumentException: memberId can't be null");
}
try {
new LocalServiceInstance(conf, address, "a", null, new HashMap<>());
} catch (Exception ex) {
assertEquals(ex.toString(), "java.lang.IllegalArgumentException: serviceName can't be null");
}
try {
new LocalServiceInstance(conf, address, "a", "b", null);
} catch (Exception ex) {
assertEquals(ex.toString(), "java.lang.IllegalArgumentException: methods can't be null");
}
try {
new LocalServiceInstance(conf, address, "a", "b", new HashMap<>()).invoke(null);
} catch (Exception ex) {
assertEquals(ex.toString(), "java.lang.IllegalArgumentException: message can't be null");
}
}
Aggregations