Record record1 = new Record() .setType("eventbus-service-proxy") .setLocation(new JsonObject().put("endpoint", "the-service-address"))
/** * Creates a new {@link SchemaReferenceData} by copying * the values from another {@link SchemaReferenceData}. * * @param other the reference state to copy */ public SchemaReferenceData(SchemaReferenceData other) { this.id = other.id; this.status = other.status; this.record = new Record(other.record); }
/** * Creates a new {@link SchemaReferenceData} from * its json representation. * * @param json the json object */ public SchemaReferenceData(JsonObject json) { this.id = json.getString("id"); this.record = new Record(json.getJsonObject("record")); this.status = "bind".equals(json.getValue("type")) ? Status.BOUND : Status.RELEASED; }
public static void publish(io.vertx.servicediscovery.spi.ServicePublisher j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.publish(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null); } public static void update(io.vertx.servicediscovery.spi.ServicePublisher j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
public static void publish(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.publish(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null); } public static void getRecord(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
public static void update(io.vertx.servicediscovery.spi.ServicePublisher j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.update(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null); } }
public static void update(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.update(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null); } public static java.util.Map<String, Object> options(io.vertx.servicediscovery.ServiceDiscovery j_receiver) {
static Record createRecord(String name, JsonObject location, JsonObject metadata) { Objects.requireNonNull(name); Objects.requireNonNull(location); Record record = new Record().setName(name) .setType(TYPE) .setLocation(location); if (metadata != null) { record.setMetadata(metadata); } return record; }
static Record createRecord(String name, JsonObject location, JsonObject metadata) { Objects.requireNonNull(name); Objects.requireNonNull(location); Record record = new Record().setName(name) .setType(TYPE) .setLocation(location); if (metadata != null) { record.setMetadata(metadata); } return record; }
@Override public void onUpdate(Record record) { state.put(record.getRegistration(), new Record(record)); }
public static io.vertx.servicediscovery.ServiceReference getReferenceWithConfiguration(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.Map<String, Object> record, java.util.Map<String, Object> configuration) { return io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.getReferenceWithConfiguration(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null, configuration != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(configuration) : null)); } public static io.vertx.servicediscovery.ServiceDiscovery registerServiceImporter(io.vertx.servicediscovery.ServiceDiscovery j_receiver, io.vertx.servicediscovery.spi.ServiceImporter importer, java.util.Map<String, Object> configuration) {
@Test public void TestTypeMatch() { Record record = new Record().setName("Name").setType(HttpEndpoint.TYPE); assertThat(record.match(new JsonObject().put("name", "Name").put("type", "any"))).isFalse(); assertThat(record.match(new JsonObject().put("name", "Name").put("type", HttpEndpoint.TYPE))).isTrue(); assertThat(record.match(new JsonObject().put("type", HttpEndpoint.TYPE))).isTrue(); assertThat(record.match(new JsonObject().put("name", "Name").put("type", "*"))).isTrue(); }
@Test public void TestTypeMatch() { Record record = new Record().setName("Name").setType(HttpEndpoint.TYPE); assertThat(record.match(new JsonObject().put("name", "Name").put("type", "any"))).isFalse(); assertThat(record.match(new JsonObject().put("name", "Name").put("type", HttpEndpoint.TYPE))).isTrue(); assertThat(record.match(new JsonObject().put("type", HttpEndpoint.TYPE))).isTrue(); assertThat(record.match(new JsonObject().put("name", "Name").put("type", "*"))).isTrue(); }
@Test(expected = IllegalArgumentException.class) public void unknown() { Record record = new Record(); record.setType(ServiceType.UNKNOWN); ServiceTypes.get(record); }
@Test(expected = IllegalArgumentException.class) public void notAKnownType() { Record record = new Record(); record.setType("bob"); ServiceTypes.get(record); }
@Test(expected = IllegalArgumentException.class) public void unknown() { Record record = new Record(); record.setType(ServiceType.UNKNOWN); ServiceTypes.get(record); }
@Test(expected = IllegalArgumentException.class) public void notAKnownType() { Record record = new Record(); record.setType("bob"); ServiceTypes.get(record); }
@Test public void should_Fail_Service_Proxy_With_Record_Status_Not_UP(TestContext context) { GraphQLClient.getSchemaProxy(discovery, new Record() .setName("DroidQueries").setType(Queryable.SERVICE_TYPE), context.asyncAssertFailure(ex -> assertEquals("Record status indicates service 'DroidQueries' is: UNKNOWN. Expected: UP", ex.getMessage()) )); }
@Test public void testFailedPublication() { HelloService svc = new HelloServiceImpl("stuff"); ProxyHelper.registerService(HelloService.class, vertx, svc, "address"); Record record = new Record() .setName("Hello") .setRegistration("this-is-not-allowed") .setLocation(new JsonObject().put(Record.ENDPOINT, "address")); Restafari.Response response = given().request().body(record.toJson().toString()).post("/discovery"); assertThat(response.getStatusCode()).isEqualTo(500); }
@Test public void testFailedPublication() { HelloService svc = new HelloServiceImpl("stuff"); ProxyHelper.registerService(HelloService.class, vertx, svc, "address"); Record record = new Record() .setName("Hello") .setRegistration("this-is-not-allowed") .setLocation(new JsonObject().put(Record.ENDPOINT, "address")); Restafari.Response response = given().request().body(record.toJson().toString()).post("/discovery"); assertThat(response.getStatusCode()).isEqualTo(500); }