Ejemplo n.º 1
0
  public void testRegisterTaskStatus() {
    NamedWriteableRegistry registry = new NamedWriteableRegistry();
    Settings settings = Settings.EMPTY;
    NetworkModule module =
        new NetworkModule(new NetworkService(settings), settings, false, registry);

    // Builtin reader comes back
    assertNotNull(registry.getReader(Task.Status.class, ReplicationTask.Status.NAME));

    module.registerTaskStatus(DummyTaskStatus.NAME, DummyTaskStatus::new);
    assertEquals(
        "test",
        expectThrows(
                UnsupportedOperationException.class,
                () -> registry.getReader(Task.Status.class, DummyTaskStatus.NAME).read(null))
            .getMessage());
  }
 static SmoothingModel copyModel(SmoothingModel original) throws IOException {
   try (BytesStreamOutput output = new BytesStreamOutput()) {
     original.writeTo(output);
     try (StreamInput in =
         new NamedWriteableAwareStreamInput(
             output.bytes().streamInput(), namedWriteableRegistry)) {
       return namedWriteableRegistry
           .getReader(SmoothingModel.class, original.getWriteableName())
           .read(in);
     }
   }
 }