Java Code Examples for com.google.common.collect.ImmutableMap#of()

The following examples show how to use com.google.common.collect.ImmutableMap#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserImportHashTest.java    From firebase-admin-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testHmacHash() {
  Map<String, UserImportHash> hashes = ImmutableMap.<String, UserImportHash>of(
      "HMAC_SHA512", HmacSha512.builder().setKey(SIGNER_KEY).build(),
      "HMAC_SHA256", HmacSha256.builder().setKey(SIGNER_KEY).build(),
      "HMAC_SHA1", HmacSha1.builder().setKey(SIGNER_KEY).build(),
      "HMAC_MD5", HmacMd5.builder().setKey(SIGNER_KEY).build()
  );
  for (Map.Entry<String, UserImportHash> entry : hashes.entrySet()) {
    Map<String, Object> properties = ImmutableMap.<String, Object>of(
        "hashAlgorithm", entry.getKey(),
        "signerKey", BaseEncoding.base64Url().encode(SIGNER_KEY)
    );
    assertEquals(properties, entry.getValue().getProperties());
  }
}
 
Example 2
Source File: ByonLocationResolverTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test(dataProvider = "windowsOsFamilies")
public void testWindowsMachines(String osFamily) throws Exception {
    brooklynProperties.put("brooklyn.location.byon.user", "myuser");
    brooklynProperties.put("brooklyn.location.byon.password", "mypassword");
    String spec = "byon";
    Map<String, ?> flags = ImmutableMap.of(
            "hosts", ImmutableList.of("1.1.1.1", "2.2.2.2"),
            "osFamily", osFamily
    );
    MachineProvisioningLocation<MachineLocation> provisioner = resolve(spec, flags);
    WinRmMachineLocation location = (WinRmMachineLocation) provisioner.obtain(ImmutableMap.of());

    assertEquals(location.config().get(WinRmMachineLocation.USER), "myuser");
    assertEquals(location.config().get(WinRmMachineLocation.PASSWORD), "mypassword");
    assertEquals(location.config().get(WinRmMachineLocation.ADDRESS).getHostAddress(), "1.1.1.1");
}
 
Example 3
Source File: PlatformMappingValueTest.java    From bazel with Apache License 2.0 6 votes vote down vote up
@Test
public void testMapNoMappingIfPlatformIsSetAndNoPlatformMapping() throws Exception {
  ImmutableMap<Collection<String>, Label> flagsToPlatforms =
      ImmutableMap.of(ImmutableList.of("--cpu=one"), PLATFORM1);

  BuildOptions modifiedOptions = DEFAULT_BUILD_CONFIG_PLATFORM_OPTIONS.clone();
  modifiedOptions.get(CoreOptions.class).cpu = "one";
  modifiedOptions.get(PlatformOptions.class).platforms = ImmutableList.of(PLATFORM2);

  PlatformMappingValue mappingValue =
      new PlatformMappingValue(ImmutableMap.of(), flagsToPlatforms);

  BuildConfigurationValue.Key mapped =
      mappingValue.map(keyForOptions(modifiedOptions), DEFAULT_BUILD_CONFIG_PLATFORM_OPTIONS);

  assertThat(keyForOptions(modifiedOptions)).isEqualTo(mapped);
}
 
Example 4
Source File: PermissionsManagerInitializationTest.java    From AuthMeReloaded with GNU General Public License v3.0 6 votes vote down vote up
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> createParameters() {
    Map<PermissionsSystemType, Class<?>> handlersByPermissionSystemType = ImmutableMap.of(
        LUCK_PERMS, LuckPermsHandler.class,
        PERMISSIONS_EX, PermissionsExHandler.class,
        Z_PERMISSIONS, ZPermissionsHandler.class,
        VAULT, VaultHandler.class);

    // Verify that all handlers are present -> reminder to add any new entry here as well
    if (!handlersByPermissionSystemType.keySet().equals(newHashSet(PermissionsSystemType.values()))) {
        throw new IllegalStateException("Test is not set up with all "
            + PermissionsSystemType.class.getSimpleName() + " entries");
    }

    // Wrap the above map in a Collection<Object[]> to satisfy JUnit
    return handlersByPermissionSystemType.entrySet().stream()
        .map(e -> new Object[]{ e.getKey(), e.getValue() })
        .collect(Collectors.toList());
}
 
Example 5
Source File: IntegrationDedicatedTaskDriverClusterSuite.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Override
protected Map<String, Config> overrideJobConfigs(Config rawJobConfig) {
  Config newConfig = ConfigFactory.parseMap(ImmutableMap.of(
      GobblinClusterConfigurationKeys.DISTRIBUTED_JOB_LAUNCHER_ENABLED, true))
      .withFallback(rawJobConfig);
  return ImmutableMap.of(JOB_NAME, newConfig);
}
 
Example 6
Source File: UpdateMessagePatchTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
public void applyStateShouldThrowWhenKeywordsContainDeletedFlag() {
    expectedException.expect(IllegalArgumentException.class);
    ImmutableMap<String, Boolean> keywords = ImmutableMap.of(
            "$Deleted", true);

    UpdateMessagePatch testee = UpdateMessagePatch.builder()
        .keywords(keywords)
        .build();

    Flags currentFlags = new Flags(Flags.Flag.SEEN);

    testee.applyToState(currentFlags);
}
 
Example 7
Source File: TestObjectsFactory.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
public static WorkspaceConfigImpl createWorkspaceConfig(String id) {
  return new WorkspaceConfigImpl(
      id + "_name",
      id + "description",
      "default-env",
      asList(createCommand(), createCommand()),
      asList(createProjectConfig(id + "-project1"), createProjectConfig(id + "-project2")),
      ImmutableMap.of(
          id + "env1", createEnv(),
          id + "env2", createEnv()),
      ImmutableMap.of("attr1", "value1", "attr2", "value2"));
}
 
Example 8
Source File: IAndroidUtils.java    From carina with Apache License 2.0 5 votes vote down vote up
/**
 * To change (grant or revoke) application permissions.
 * 
 * @param packageName String
 * @param action PermissionAction
 * @param permissions Permission
 */
default public void changePermissions(String packageName, PermissionAction action, Permission... permissions) {
    ArrayList<String> permissionsStr = new ArrayList<>();
    Arrays.asList(permissions).forEach(p -> permissionsStr.add(p.getPermission()));
    Map<String, Object> preparedCommand = ImmutableMap.of("action", action.getAction(), "appPackage", packageName,
            "permissions", permissionsStr);
    ((AppiumDriver<?>) castDriver()).executeScript(SHELL_INIT_CHANGE_PERMISSION_CONSOLE, preparedCommand);
}
 
Example 9
Source File: SchemaConversionBuilderTest.java    From kafka-connect-spooldir with Apache License 2.0 5 votes vote down vote up
@Test
  public void foo() {
    ElfParser parser = mock(ElfParser.class);
    final Map<String, Class<?>> fieldTypes = ImmutableMap.of(
        "date", LocalDate.class,
        "time", LocalTime.class,
        "sc-bytes", Long.class,
        "sc-status", Integer.class
    );
    final Map<String, Object> fieldData = ImmutableMap.of(
        "date", LocalDate.of(2011, 3, 14),
        "time", LocalTime.of(12, 0, 0),
        "sc-bytes", 12341L,
        "sc-status", 200
    );
    when(parser.fieldTypes()).thenReturn(fieldTypes);

    SchemaConversionBuilder schemaGenerator = new SchemaConversionBuilder(parser);
    SchemaConversion conversion = schemaGenerator.build();
    assertNotNull(conversion, "conversion should not be null.");

    LogEntry entry = mock(LogEntry.class);
    when(entry.fieldTypes()).thenReturn(fieldTypes);
    when(entry.fieldData()).thenReturn(fieldData);

    SchemaAndValue actual = conversion.convert(entry);
    assertNotNull(actual, "actual should not be null");
//    assertNotNull(actual.getKey(), "actual.getKey() should not be null");
    assertNotNull(actual.schema(), "actual.getValue() should not be null");
    assertNotNull(actual.value(), "actual.getValue() should not be null");

//    actual.getValue()..validate();

//date time x-edge-location sc-bytes c-ip cs-method cs(Host) cs-uri-stem sc-status cs(Referer) cs(User-Agent) cs-uri-query cs(Cookie) x-edge-result-type x-edge-request-id x-host-header cs-protocol cs-bytes time-taken


  }
 
Example 10
Source File: NonMatchingAcceptanceTest.java    From verify-service-provider with MIT License 5 votes vote down vote up
@Test
public void shouldProcessIdpResponseCorrectlyWhenEuropeanIdentityConfigAbsent() {
    Client client = application.client();
    ComplianceToolService complianceTool = new ComplianceToolService(client);
    GenerateRequestService generateRequestService = new GenerateRequestService(client);

    complianceTool.initialiseWithDefaultsForV2();

    RequestResponseBody requestResponseBody = generateRequestService.generateAuthnRequest(application.getLocalPort());
    Map<String, String> translateResponseRequestData = ImmutableMap.of(
            "samlResponse", complianceTool.createResponseFor(requestResponseBody.getSamlRequest(), VERIFIED_USER_ON_SERVICE_WITH_NON_MATCH_SETTING_ID),
            "requestId", requestResponseBody.getRequestId(),
            "levelOfAssurance", LEVEL_1.name()
    );

    Response response = client
            .target(String.format("http://localhost:%d/translate-response", application.getLocalPort()))
            .request()
            .buildPost(json(translateResponseRequestData))
            .invoke();

    assertThat(response.getStatus()).isEqualTo(OK.getStatusCode());

    JSONObject jsonResponse = new JSONObject(response.readEntity(String.class));
    assertThat(jsonResponse.getString("scenario")).isEqualTo(IDENTITY_VERIFIED.name());
    assertThat(jsonResponse.getString("levelOfAssurance")).isEqualTo(LEVEL_1.name());
}
 
Example 11
Source File: UserProviderTest.java    From firebase-admin-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testRequiredProperties() throws IOException {
  UserProvider provider = UserProvider.builder()
      .setUid("testuid")
      .setProviderId("google.com")
      .build();
  String json = JSON_FACTORY.toString(provider);
  Map<String, Object> parsed = new HashMap<>();
  JSON_FACTORY.createJsonParser(json).parse(parsed);
  Map<String, Object> expected = ImmutableMap.<String, Object>of(
      "rawId", "testuid",
      "providerId", "google.com"
  );
  assertEquals(expected, parsed);
}
 
Example 12
Source File: SkylarkUserDefinedRuleTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void returnsParamInfos() throws EvalException {

  ImmutableMap<String, AttributeHolder> params =
      ImmutableMap.of("arg1", StringAttribute.of("some string", "", false, ImmutableList.of()));
  SkylarkUserDefinedRule rule =
      SkylarkUserDefinedRule.of(
          Location.BUILTIN,
          SimpleFunction.of(1),
          TEST_IMPLICIT_ATTRIBUTES,
          HIDDEN_IMPLICIT_ATTRIBUTES,
          params,
          false,
          false);

  ImmutableMap<String, ParamInfo<?>> paramInfos = rule.getAllParamInfo();

  assertEquals(ImmutableSet.of("name", "arg1"), paramInfos.keySet());

  SkylarkParamInfo name = (SkylarkParamInfo) paramInfos.get("name");
  SkylarkParamInfo arg1 = (SkylarkParamInfo) paramInfos.get("arg1");

  assertEquals("name", name.getName());
  assertEquals(
      StringAttribute.of("", "The name of the target", true, ImmutableList.of()), name.getAttr());

  assertEquals("arg1", arg1.getName());
  assertEquals(params.get("arg1").getAttribute(), arg1.getAttr());
}
 
Example 13
Source File: TestLocalStoreMonitor.java    From samza with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

  // Create a different local store directory every time the test is executed to avoid
  // intermittent test failures due to previous unsuccessful test re-runs.
  localStoreDir = Files.createTempDir();
  jobDir = new File(localStoreDir, "test-jobName-jobId");
  taskStoreDir = new File(new File(jobDir, "test-store"), "test-task");

  config = ImmutableMap.of(LocalStoreMonitorConfig.CONFIG_LOCAL_STORE_DIR, localStoreDir.getCanonicalPath());

  // Make scaffold directories for testing.
  FileUtils.forceMkdir(taskStoreDir);
  taskStoreSize = taskStoreDir.getTotalSpace();

  // Set default return values for methods.
  Mockito.when(jobsClientMock.getJobStatus(Mockito.any())).thenReturn(JobStatus.STOPPED);
  Task task = new Task("localHost", "test-task", "0", new ArrayList<>(), ImmutableList.of("test-store"));
  Mockito.when(jobsClientMock.getTasks(Mockito.any())).thenReturn(ImmutableList.of(task));

  localStoreMonitorMetrics = new LocalStoreMonitorMetrics("TestMonitorName", new NoOpMetricsRegistry());

  // Initialize the local store monitor with mock and config
  localStoreMonitor =
      new LocalStoreMonitor(new LocalStoreMonitorConfig(new MapConfig(config)), localStoreMonitorMetrics,
          jobsClientMock);
}
 
Example 14
Source File: ComponentXOFactoryTest.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Map<String, Object> getDecoratedExtraJsonAttributes() {
  return ImmutableMap.of("foo", "bar");
}
 
Example 15
Source File: MarketDataTest.java    From Strata with Apache License 2.0 4 votes vote down vote up
@Test
public void test_withValue() {
  Map<MarketDataId<?>, Object> dataMap = ImmutableMap.of(ID1, VAL1);
  MarketData test = MarketData.of(VAL_DATE, dataMap).withValue(ID1, VAL3);
  assertThat(test.getValue(ID1)).isEqualTo(VAL3);
}
 
Example 16
Source File: TestTransactionalStateTaskRestoreManager.java    From samza with Apache License 2.0 4 votes vote down vote up
/**
 * This can happen if no new messages were written to the store between commits. There may be more than one store
 * checkpoint if container fails during commit after creating a checkpoint but before deleting the old one.
 */
@Test
public void testGetStoreActionsForLoggedPersistentStore_RetainOneCheckpointIfMultipleCheckpointsWithSameOffset() {
  TaskModel mockTaskModel = mock(TaskModel.class);
  TaskName taskName = new TaskName("Partition 0");
  when(mockTaskModel.getTaskName()).thenReturn(taskName);
  Partition taskChangelogPartition = new Partition(0);
  when(mockTaskModel.getChangelogPartition()).thenReturn(taskChangelogPartition);

  String store1Name = "store1";
  StorageEngine store1Engine = mock(StorageEngine.class);
  StoreProperties mockStore1Properties = mock(StoreProperties.class);
  when(store1Engine.getStoreProperties()).thenReturn(mockStore1Properties);
  when(mockStore1Properties.isLoggedStore()).thenReturn(true);
  when(mockStore1Properties.isPersistedToDisk()).thenReturn(true);
  Map<String, StorageEngine> mockStoreEngines = ImmutableMap.of(store1Name, store1Engine);

  String changelog1SystemName = "system1";
  String changelog1StreamName = "store1Changelog";
  SystemStream changelog1SystemStream = new SystemStream(changelog1SystemName, changelog1StreamName);
  SystemStreamPartition changelog1SSP = new SystemStreamPartition(changelog1SystemStream, taskChangelogPartition);
  SystemStreamPartitionMetadata changelog1SSPMetadata = new SystemStreamPartitionMetadata("0", "10", "11");
  Map<String, SystemStream> mockStoreChangelogs = ImmutableMap.of(store1Name, changelog1SystemStream);

  String changelog1CheckpointedOffset = "5";
  CheckpointedChangelogOffset changelog1CheckpointMessage =
      new CheckpointedChangelogOffset(CheckpointId.create(), changelog1CheckpointedOffset);
  ImmutableMap<SystemStreamPartition, String> mockCheckpointedChangelogOffset =
      ImmutableMap.of(changelog1SSP, changelog1CheckpointMessage.toString());
  Map<SystemStreamPartition, SystemStreamPartitionMetadata> mockCurrentChangelogOffsets =
      ImmutableMap.of(changelog1SSP, changelog1SSPMetadata);

  SystemAdmins mockSystemAdmins = mock(SystemAdmins.class);
  SystemAdmin mockSystemAdmin = mock(SystemAdmin.class);
  when(mockSystemAdmins.getSystemAdmin(changelog1SSP.getSystem())).thenReturn(mockSystemAdmin);
  StorageManagerUtil mockStorageManagerUtil = mock(StorageManagerUtil.class);
  File mockLoggedStoreBaseDir = mock(File.class);
  File mockNonLoggedStoreBaseDir = mock(File.class);
  Config mockConfig = mock(Config.class);
  Clock mockClock = mock(Clock.class);

  File mockCurrentStoreDir = mock(File.class);
  File mockStoreNewerCheckpointDir = mock(File.class);
  File mockStoreOlderCheckpointDir = mock(File.class);
  when(mockStorageManagerUtil.getTaskStoreDir(eq(mockLoggedStoreBaseDir), eq(store1Name), eq(taskName), any()))
      .thenReturn(mockCurrentStoreDir);
  when(mockStorageManagerUtil.getTaskStoreCheckpointDirs(eq(mockLoggedStoreBaseDir), eq(store1Name), eq(taskName), any()))
      .thenReturn(ImmutableList.of(mockStoreNewerCheckpointDir, mockStoreOlderCheckpointDir));
  when(mockStorageManagerUtil.isLoggedStoreValid(eq(store1Name), eq(mockStoreNewerCheckpointDir), any(),
      eq(mockStoreChangelogs), eq(mockTaskModel), any(), eq(mockStoreEngines))).thenReturn(true);
  when(mockStorageManagerUtil.isLoggedStoreValid(eq(store1Name), eq(mockStoreOlderCheckpointDir), any(),
      eq(mockStoreChangelogs), eq(mockTaskModel), any(), eq(mockStoreEngines))).thenReturn(true);
  Set<SystemStreamPartition> mockChangelogSSPs = ImmutableSet.of(changelog1SSP);
  when(mockStorageManagerUtil.readOffsetFile(eq(mockStoreNewerCheckpointDir), eq(mockChangelogSSPs), eq(false)))
      .thenReturn(ImmutableMap.of(changelog1SSP, changelog1CheckpointedOffset));  // equal to checkpointed offset (5)
  when(mockStorageManagerUtil.readOffsetFile(eq(mockStoreOlderCheckpointDir), eq(mockChangelogSSPs), eq(false)))
      .thenReturn(ImmutableMap.of(changelog1SSP, changelog1CheckpointedOffset)); // also equal to checkpointed offset (5)

  Mockito.when(mockSystemAdmin.offsetComparator(anyString(), anyString()))
      .thenAnswer((Answer<Integer>) invocation -> {
        String offset1 = (String) invocation.getArguments()[0];
        String offset2 = (String) invocation.getArguments()[1];
        return Long.valueOf(offset1).compareTo(Long.valueOf(offset2));
      });

  StoreActions storeActions = TransactionalStateTaskRestoreManager.getStoreActions(
      mockTaskModel, mockStoreEngines, mockStoreChangelogs, mockCheckpointedChangelogOffset,
      mockCurrentChangelogOffsets, mockSystemAdmins, mockStorageManagerUtil,
      mockLoggedStoreBaseDir, mockNonLoggedStoreBaseDir, mockConfig, mockClock);

  // ensure that both the current dir and one of the checkpoint dirs are marked for deletion
  assertEquals(2, storeActions.storeDirsToDelete.get(store1Name).size());
  assertTrue(storeActions.storeDirsToDelete.get(store1Name).contains(mockCurrentStoreDir));
  // ensure that the one of the store checkpoint is marked for retention
  assertNotNull(storeActions.storeDirsToRetain.get(store1Name));
  // ensure that we mark the store for restore even if local offset == checkpointed offset
  // this is required since there may be message we need to trim
  assertEquals(changelog1CheckpointedOffset, storeActions.storesToRestore.get(store1Name).startingOffset);
  assertEquals(changelog1CheckpointedOffset, storeActions.storesToRestore.get(store1Name).endingOffset);
}
 
Example 17
Source File: IpcdBridgeConfigModule.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Provides @Named("tcpChannelOptions")
public Map<ChannelOption<?>, Object> provideTcpChannelOptions(BridgeServerConfig serverConfig) {
   return ImmutableMap.of(
      ChannelOption.SO_KEEPALIVE, serverConfig.isSoKeepAlive()
   );
}
 
Example 18
Source File: SubnetTest.java    From batfish with Apache License 2.0 4 votes vote down vote up
/** Tests that we do the right thing when processing a route for transit gateway. */
@Test
public void testProcessRouteTransitGateway() {
  Vpc vpc = new Vpc("vpc", ImmutableSet.of(), ImmutableMap.of());
  Configuration vpcCfg = Utils.newAwsConfiguration(vpc.getId(), "awstest");

  Prefix subnetPrefix = Prefix.parse("10.10.10.0/24");
  Prefix remotePrefix = Prefix.parse("192.168.0.0/16");

  Subnet subnet = new Subnet(subnetPrefix, "subnet", vpc.getId(), "zone", ImmutableMap.of());
  Configuration subnetCfg = Utils.newAwsConfiguration(subnet.getId(), "awstest");

  TransitGatewayVpcAttachment tgwVpcAttachment =
      new TransitGatewayVpcAttachment(
          "attachment", "tgw", vpc.getId(), ImmutableList.of(subnet.getId()));
  String linkId = tgwVpcAttachment.getId();

  Region region =
      Region.builder("region")
          .setSubnets(ImmutableMap.of(subnet.getId(), subnet))
          .setVpcs(ImmutableMap.of(vpc.getId(), vpc))
          .setTransitGatewayVpcAttachments(
              ImmutableMap.of(tgwVpcAttachment.getId(), tgwVpcAttachment))
          .build();

  RouteV4 route =
      new RouteV4(
          remotePrefix, State.ACTIVE, tgwVpcAttachment.getGatewayId(), TargetType.TransitGateway);

  ConvertedConfiguration awsConfiguration = new ConvertedConfiguration(ImmutableMap.of());

  vpcCfg
      .getVrfs()
      .put(
          vrfNameForLink(linkId),
          Vrf.builder().setOwner(vpcCfg).setName(vrfNameForLink(linkId)).build());
  connect(
      awsConfiguration,
      subnetCfg,
      DEFAULT_VRF_NAME,
      vpcCfg,
      vrfNameForLink(linkId),
      vrfNameForLink(linkId));
  subnet.processRoute(
      subnetCfg, region, route, vpcCfg, ImmutableList.of(), awsConfiguration, new Warnings());

  testProcessRouteHelper(route, linkId, vpcCfg, subnetCfg);
}
 
Example 19
Source File: EvpnType5CumulusTest.java    From batfish with Apache License 2.0 4 votes vote down vote up
@Test(expected = AssertionError.class) // xfail this until type 5 routes aren't broken
public void testType5RoutePresence() throws IOException {
  String snapshotName = "evpn-type5-routes";
  List<String> configurationNames =
      ImmutableList.of(
          "leaf1", "leaf2", "leaf3", "leaf4", "spine1", "spine2", "exitgateway", "internet");
  Batfish batfish =
      BatfishTestUtils.getBatfishFromTestrigText(
          TestrigText.builder()
              .setConfigurationFiles(SNAPSHOT_PREFIX + snapshotName, configurationNames)
              .setLayer1TopologyPrefix(SNAPSHOT_PREFIX + snapshotName)
              .build(),
          _folder);

  batfish.computeDataPlane(batfish.getSnapshot()); // compute and cache the dataPlane
  DataPlane dp = batfish.loadDataPlane(batfish.getSnapshot());

  SortedMap<String, SortedMap<String, GenericRib<AnnotatedRoute<AbstractRoute>>>> ribs =
      dp.getRibs();
  String vrf1 = "vrf1";
  final ImmutableList<String> leafs = ImmutableList.of("leaf1", "leaf2", "leaf3", "leaf4");

  ImmutableSet<Prefix> prefixes =
      ImmutableSet.of(
          Ip.parse("100.100.100.100").toPrefix(), Ip.parse("100.100.100.101").toPrefix());

  Map<String, Set<String>> nextHopInterfaces =
      ImmutableMap.of(
          "leaf1",
          ImmutableSet.of("swp1", "swp11"),
          "leaf2",
          ImmutableSet.of("swp2", "swp12"),
          "leaf3",
          ImmutableSet.of("swp3", "swp13"),
          "leaf4",
          ImmutableSet.of("swp4", "swp14"));

  for (String leaf : leafs) {
    Set<AbstractRoute> routes = ribs.get(leaf).get(vrf1).getRoutes();
    for (Prefix prefix : prefixes) {
      for (String nextHopIface : nextHopInterfaces.get(leaf)) {
        assertThat(
            routes,
            hasItem(
                isEvpnType5RouteThat(
                    allOf(hasPrefix(prefix), hasNextHopInterface(nextHopIface)))));
      }
    }
  }
}
 
Example 20
Source File: IOSMobileCommandHelper.java    From java-client with Apache License 2.0 2 votes vote down vote up
/**
 * This method forms a {@link Map} of parameters for the device shaking.
 *
 * @return a key-value pair. The key is the command name. The value is a {@link Map} command arguments.
 */
public static Map.Entry<String, Map<String, ?>>  shakeCommand() {
    return new AbstractMap.SimpleEntry<>(SHAKE, ImmutableMap.of());
}