public static void writeIdlProtocol(Writer writer, Protocol protocol) throws IOException {
    final String protocolFullName = protocol.getName();
    final int lastDotPos = protocolFullName.lastIndexOf(".");
    final String protocolNameSpace;
    if (lastDotPos < 0) {
      protocolNameSpace = protocol.getNamespace();
    } else if (lastDotPos > 0) {
      protocolNameSpace = protocolFullName.substring(0, lastDotPos);
    } else {
      protocolNameSpace = null;
    }
    writeIdlProtocol(writer, protocol, protocolNameSpace, protocolFullName.substring(lastDotPos + 1),
        protocol.getTypes(), protocol.getMessages().values());
  }
@Test
  public void cannotWriteProtocolWithUnnamedTypes() {
    assertThrows(AvroRuntimeException.class,
        () -> IdlUtils.writeIdlProtocol(new StringWriter(), Schema.create(Schema.Type.STRING)));
  }