@JsonCreator private static @Nonnull CompletionMetadata create( @Nullable @JsonProperty(PROP_ADDRESS_BOOKS) Set<String> addressBooks, @Nullable @JsonProperty(PROP_ADDRESS_GROUPS) Set<String> addressGroups, @Nullable @JsonProperty(PROP_FILTER_NAMES) Set<String> filterNames, @Nullable @JsonProperty(PROP_INTERFACES) Set<NodeInterfacePair> interfaces, @Nullable @JsonProperty(PROP_IPS) Set<String> ips, @Nullable @JsonProperty(PROP_PREFIXES) Set<String> prefixes, @Nullable @JsonProperty(PROP_STRUCTURE_NAMES) Set<String> structureNames, @Nullable @JsonProperty(PROP_VRFS) Set<String> vrfs, @Nullable @JsonProperty(PROP_ZONES) Set<String> zones) { return new CompletionMetadata( firstNonNull(addressBooks, ImmutableSet.of()), firstNonNull(addressGroups, ImmutableSet.of()), firstNonNull(filterNames, ImmutableSet.of()), firstNonNull(interfaces, ImmutableSet.of()), firstNonNull(ips, ImmutableSet.of()), firstNonNull(prefixes, ImmutableSet.of()), firstNonNull(structureNames, ImmutableSet.of()), firstNonNull(vrfs, ImmutableSet.of()), firstNonNull(zones, ImmutableSet.of())); }
@Test public void testCompletionMetadataRoundtrip() throws IOException { NetworkId networkId = new NetworkId("network"); SnapshotId snapshotId = new SnapshotId("snapshot"); CompletionMetadata completionMetadata = new CompletionMetadata( ImmutableSet.of("addressBook1"), ImmutableSet.of("addressGroup1"), ImmutableSet.of("filter1"), ImmutableSet.of(new NodeInterfacePair("node", "iface")), ImmutableSet.of("1.1.1.1"), ImmutableSet.of("1.1.1.1/30"), ImmutableSet.of("structure1"), ImmutableSet.of("vrf1"), ImmutableSet.of("zone1")); _storage.storeCompletionMetadata(completionMetadata, networkId, snapshotId); assertThat(_storage.loadCompletionMetadata(networkId, snapshotId), equalTo(completionMetadata)); }
private CompletionMetadata computeCompletionMetadata(Map<String, Configuration> configurations) { ReferenceLibrary referenceLibrary = getReferenceLibraryData(); return new CompletionMetadata( getAddressBooks(referenceLibrary), getAddressGroups(referenceLibrary), getFilterNames(configurations), getInterfaces(configurations), getIps(configurations), getPrefixes(configurations), getStructureNames(configurations), getVrfs(configurations), getZones(configurations)); }