@Test public void load () { ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("connector.yml").getFile()); Config config = Config.load(file); Defaults defaults = config.getDefaults(); assertThat(defaults) .isNotNull(); SoftAssertions.assertSoftly(softly -> { softly.assertThat(defaults.getEpmdPort()) .isEqualTo(8888); softly.assertThat(defaults.getType()) .isEqualTo(R3_ERLANG); softly.assertThat(defaults.getShortName()) .isTrue(); softly.assertThat(defaults.getCookie()) .isEqualTo("secret"); softly.assertThat(defaults.getProtocol()) .isEqualTo(UDP); softly.assertThat(defaults.getLowVersion()) .isEqualTo(R4); softly.assertThat(defaults.getHighVersion()) .isEqualTo(R6); softly.assertThat(defaults.getDistributionFlags()) .contains(MAP_TAG, BIG_CREATION); softly.assertThat(defaults.getServer()) .isNotNull(); softly.assertThat(defaults.getServer().getPort()) .isNull(); softly.assertThat(defaults.getServer().getBossThreads()) .isEqualTo(2); softly.assertThat(defaults.getServer().getWorkerThreads()) .isEqualTo(4); }); Map<String, NodeConfig> nodes = config.getNodes(); assertThat(nodes).isNotNull(); NodeConfig node1 = nodes.get("node-1"); assertThat(node1).isNotNull(); SoftAssertions.assertSoftly(softly -> { softly.assertThat(node1.getEpmdPort()) .isEqualTo(7373); softly.assertThat(node1.getType()) .isEqualTo(R3_HIDDEN); softly.assertThat(node1.getShortName()) .isTrue(); softly.assertThat(node1.getCookie()) .isEqualTo("non-secret"); softly.assertThat(node1.getProtocol()) .isEqualTo(SCTP); softly.assertThat(node1.getLowVersion()) .isEqualTo(R5C); softly.assertThat(node1.getHighVersion()) .isEqualTo(R6); softly.assertThat(node1.getDistributionFlags()).contains( EXTENDED_REFERENCES, EXTENDED_PIDS_PORTS, BIT_BINARIES, NEW_FLOATS, FUN_TAGS, NEW_FUN_TAGS, UTF8_ATOMS, MAP_TAG, BIG_CREATION ); softly.assertThat(node1.getMailboxes()) .isNotEmpty(); MailboxConfig mailbox1 = node1.getMailboxes() .stream() .filter(it -> "net_kernel".equals(it.getName())) .findFirst() .orElse(null); assertThat(mailbox1).isNotNull(); MailboxConfig mailbox2 = node1.getMailboxes() .stream() .filter(it -> "another".equals(it.getName())) .findFirst() .orElse(null); assertThat(mailbox2).isNotNull(); MailboxConfig mailbox3 = node1.getMailboxes() .stream() .filter(it -> "another_one".equals(it.getName())) .findFirst() .orElse(null); assertThat(mailbox3).isNotNull(); softly.assertThat(node1.getServer()) .isNotNull(); softly.assertThat(node1.getServer().getPort()) .isEqualTo(8971); softly.assertThat(node1.getServer().getBossThreads()) .isEqualTo(1); softly.assertThat(node1.getServer().getWorkerThreads()) .isEqualTo(2); }); NodeConfig node2 = nodes.get("node-2"); assertThat(node2).isNotNull(); SoftAssertions.assertSoftly(softly -> { softly.assertThat(node2.getEpmdPort()) .isEqualTo(8888); softly.assertThat(node2.getType()) .isEqualTo(R3_ERLANG); softly.assertThat(node2.getShortName()) .isFalse(); softly.assertThat(node2.getCookie()) .isEqualTo("popa"); softly.assertThat(node2.getProtocol()) .isEqualTo(UDP); softly.assertThat(node2.getLowVersion()) .isEqualTo(R4); softly.assertThat(node2.getHighVersion()) .isEqualTo(R6); softly.assertThat(node2.getDistributionFlags()).contains( MAP_TAG, BIG_CREATION ); softly.assertThat(node2.getMailboxes()) .isNotEmpty(); MailboxConfig mailbox1 = node2.getMailboxes() .stream() .filter(it -> "net_kernel".equals(it.getName())) .findFirst() .orElse(null); assertThat(mailbox1).isNotNull(); softly.assertThat(node2.getServer()) .isNotNull(); softly.assertThat(node2.getServer().getPort()) .isNotNull(); softly.assertThat(node2.getServer().getBossThreads()) .isEqualTo(2); softly.assertThat(node2.getServer().getWorkerThreads()) .isEqualTo(4); }); }
public static Config load (@NonNull String fileName) { val file = new File(fileName); return load(file); }
Config { public static Config load (@NonNull String fileName) { val file = new File(fileName); return load(file); } }
Config { public static Config load (@NonNull String fileName) { val file = new File(fileName); return load(file); } Config(Config config); @Builder private  Config(Defaults defaults, @Singular Map<String, NodeConfig> nodes); }
Config { public static Config load (@NonNull String fileName) { val file = new File(fileName); return load(file); } Config(Config config); @Builder private  Config(Defaults defaults, @Singular Map<String, NodeConfig> nodes); static Config load(@NonNull String fileName); static Config load(@NonNull Path path); @SuppressWarnings("unchecked") static Config load(@NonNull File file); }
Config { public static Config load (@NonNull String fileName) { val file = new File(fileName); return load(file); } Config(Config config); @Builder private  Config(Defaults defaults, @Singular Map<String, NodeConfig> nodes); static Config load(@NonNull String fileName); static Config load(@NonNull Path path); @SuppressWarnings("unchecked") static Config load(@NonNull File file);  }