Java Code Examples for java.util.List#of()

The following examples show how to use java.util.List#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: PgExpandArray.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
@SafeVarargs
public final Iterable<Row> evaluate(TransactionContext txnCtx, Input<List<Object>>... args) {
    List<Object> values = args[0].value();
    if (values == null) {
        return List.of();
    }
    return () -> values.stream()
        .map(new Function<Object, Row>() {

            final Object[] columns = new Object[2];
            final RowN row = new RowN(columns);

            int idx = 0;

            @Override
            public Row apply(Object val) {
                idx++;
                columns[0] = val;
                columns[1] = idx;
                return row;
            }
        }).iterator();
}
 
Example 2
Source File: ChainManager.java    From nuls-v2 with MIT License 6 votes vote down vote up
/**
 * 注册智能合约交易
 * */
public void registerContractTx(){
    for (Chain chain:chainMap.values()) {
        /*
         * 注册智能合约交易
         * Chain Trading Registration
         * */
        int chainId = chain.getConfig().getChainId();
        List<CmdRegisterDto> cmdRegisterDtoList = new ArrayList<>();
        CmdRegisterDto createAgentDto = new CmdRegisterDto("cs_createContractAgent", 0, List.of("packingAddress", "deposit", "commissionRate"), 1);
        CmdRegisterDto depositDto = new CmdRegisterDto("cs_contractDeposit", 0, List.of("agentHash", "deposit"), 1);
        CmdRegisterDto stopAgentDto = new CmdRegisterDto("cs_stopContractAgent", 0, List.of(), 1);
        CmdRegisterDto cancelDepositDto = new CmdRegisterDto("cs_contractWithdraw", 0, List.of("joinAgentHash"), 1);
        CmdRegisterDto searchAgentInfo = new CmdRegisterDto("cs_getContractAgentInfo", 1, List.of("agentHash"), 1);
        CmdRegisterDto searchDepositInfo = new CmdRegisterDto("cs_getContractDepositInfo", 1, List.of("joinAgentHash"), 1);
        cmdRegisterDtoList.add(cancelDepositDto);
        cmdRegisterDtoList.add(createAgentDto);
        cmdRegisterDtoList.add(stopAgentDto);
        cmdRegisterDtoList.add(depositDto);
        cmdRegisterDtoList.add(searchAgentInfo);
        cmdRegisterDtoList.add(searchDepositInfo);
        CallMethodUtils.registerContractTx(chainId, cmdRegisterDtoList);
    }
}
 
Example 3
Source File: Eth1Data.java    From teku with Apache License 2.0 5 votes vote down vote up
@Override
public List<Bytes> get_fixed_parts() {
  return List.of(
      SSZ.encode(writer -> writer.writeFixedBytes(getDeposit_root())),
      SSZ.encodeUInt64(getDeposit_count().longValue()),
      SSZ.encode(writer -> writer.writeFixedBytes(getBlock_hash())));
}
 
Example 4
Source File: SendRequestTest.java    From tessera with Apache License 2.0 5 votes vote down vote up
@Test(expected = NullPointerException.class)
public void buildWithoutSender() {
    byte[] payload = "Payload".getBytes();

    List<PublicKey> recipients = List.of(mock(PublicKey.class));

    SendRequest.Builder.create()
        .withPayload(payload)
        .withRecipients(recipients)
        .build();
}
 
Example 5
Source File: ElementNameSearch.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Override
public List<WebElement> search(SearchContext searchContext, SearchParameters parameters)
{
    if (null != searchContext)
    {
        String elementName = parameters.getValue();
        return findElementsByText(searchContext,
                LocatorUtil.getXPathLocator(".//*[@*=%1$s or text()=%1$s]", elementName), parameters, "*");
    }
    return List.of();
}
 
Example 6
Source File: MapBasedDeviceConnectionServiceTest.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Verifies that the <em>getCommandHandlingAdapterInstances</em> operation fails for a device with a non-empty set
 * of given viaGateways, if no matching instance has been registered.
 *
 * @param ctx The vert.x context.
 */
@Test
public void testGetCommandHandlingAdapterInstancesFailsWithGivenGateways(final VertxTestContext ctx) {
    final String deviceId = "testDevice";
    final String gatewayId = "gw-1";
    final List<String> viaGateways = List.of(gatewayId);
    svc.getCommandHandlingAdapterInstances(Constants.DEFAULT_TENANT, deviceId, viaGateways, span)
            .onComplete(ctx.succeeding(result -> ctx.verify(() -> {
                assertEquals(HttpURLConnection.HTTP_NOT_FOUND, result.getStatus());
                ctx.completeNow();
            })));
}
 
Example 7
Source File: RelationName.java    From crate with Apache License 2.0 5 votes vote down vote up
public QualifiedName toQualifiedName() {
    if (schema == null) {
        return new QualifiedName(name);
    } else {
        return new QualifiedName(List.of(schema, name));
    }
}
 
Example 8
Source File: UmsUsersStateProvider.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private List<MachineUser> getMachineUsers(String actorCrn, String accountId, Optional<String> requestIdOptional,
    boolean fullSync, Set<String> machineUserCrns) {
    if (fullSync) {
        return grpcUmsClient.listAllMachineUsers(actorCrn, accountId, requestIdOptional);
    } else if (!machineUserCrns.isEmpty()) {
        return grpcUmsClient.listMachineUsers(actorCrn, accountId, List.copyOf(machineUserCrns), requestIdOptional);
    } else {
        return List.of();
    }
}
 
Example 9
Source File: BeaconBlockHeader.java    From teku with Apache License 2.0 5 votes vote down vote up
@Override
public List<Bytes> get_fixed_parts() {
  return List.of(
      SSZ.encodeUInt64(getSlot().longValue()),
      SSZ.encodeUInt64(getProposer_index().longValue()),
      SSZ.encode(writer -> writer.writeFixedBytes(getParent_root())),
      SSZ.encode(writer -> writer.writeFixedBytes(getState_root())),
      SSZ.encode(writer -> writer.writeFixedBytes(getBody_root())));
}
 
Example 10
Source File: ExecRequest.java    From milkman with MIT License 5 votes vote down vote up
@Override
protected List<Option> createOptions() {
	return List.of(
			new Option("less", "l", "outputs response into less"),
			new Option("verbose", "v", "outputs all aspects")
	);
}
 
Example 11
Source File: FabricFilteringPipelinerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
private Collection<FlowRule> buildExpectedFwdClassifierRule(PortNumber inPort,
                                                            MacAddress dstMac,
                                                            MacAddress dstMacMask,
                                                            short ethType,
                                                            byte fwdClass) {
    PiActionParam classParam = new PiActionParam(FabricConstants.FWD_TYPE,
                                                 ImmutableByteSequence.copyFrom(fwdClass));
    PiAction fwdClassifierAction = PiAction.builder()
            .withId(FabricConstants.FABRIC_INGRESS_FILTERING_SET_FORWARDING_TYPE)
            .withParameter(classParam)
            .build();
    TrafficTreatment treatment = DefaultTrafficTreatment.builder()
            .piTableAction(fwdClassifierAction)
            .build();

    TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder()
            .matchInPort(inPort);
    if (dstMacMask != null) {
        sbuilder.matchEthDstMasked(dstMac, dstMacMask);
    } else {
        sbuilder.matchEthDstMasked(dstMac, MacAddress.EXACT_MASK);
    }
    // Special case for MPLS UNICAST forwarding, need to build 2 rules for MPLS+IPv4 and MPLS+IPv6
    if (ethType == Ethernet.MPLS_UNICAST) {
        return buildExpectedFwdClassifierRulesMpls(fwdClassifierAction, treatment, sbuilder);
    }
    sbuilder.matchPi(PiCriterion.builder()
                             .matchExact(FabricConstants.HDR_IP_ETH_TYPE, ethType)
                             .build());
    TrafficSelector selector = sbuilder.build();
    return List.of(DefaultFlowRule.builder()
                           .withPriority(PRIORITY)
                           .withSelector(selector)
                           .withTreatment(treatment)
                           .fromApp(APP_ID)
                           .forDevice(DEVICE_ID)
                           .makePermanent()
                           .forTable(FabricConstants.FABRIC_INGRESS_FILTERING_FWD_CLASSIFIER)
                           .build());
}
 
Example 12
Source File: YarnResourceManagerRoleConfigProvider.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Override
protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) {
    switch (roleType) {
        case YarnRoles.RESOURCEMANAGER:
            return List.of(
                    config(CAPACITY_SCHEDULER_SAFETY_VALVE, ConfigUtils.getSafetyValveConfiguration(getCapacitySchedulerValveValue())),
                    config(CAPACITY_SCHEDULER_CLASS, "org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler"));
        default:
            return List.of();
    }
}
 
Example 13
Source File: ConfigServerBootstrapTest.java    From vespa with Apache License 2.0 5 votes vote down vote up
@Test
public void testBootstrap() throws Exception {
    ConfigserverConfig configserverConfig = createConfigserverConfig(temporaryFolder);
    InMemoryProvisioner provisioner = new InMemoryProvisioner(true, "host0", "host1", "host3", "host4");
    DeployTester tester = new DeployTester(List.of(createHostedModelFactory()), configserverConfig, provisioner);
    tester.deployApp("src/test/apps/hosted/");

    File versionFile = temporaryFolder.newFile();
    VersionState versionState = new VersionState(versionFile);
    assertTrue(versionState.isUpgraded());

    RpcServer rpcServer = createRpcServer(configserverConfig);
    // Take a host away so that there are too few for the application, to verify we can still bootstrap
    provisioner.allocations().values().iterator().next().remove(0);
    StateMonitor stateMonitor = new StateMonitor();
    VipStatus vipStatus = createVipStatus(stateMonitor);
    ConfigServerBootstrap bootstrap = new ConfigServerBootstrap(tester.applicationRepository(), rpcServer,
                                                                versionState, stateMonitor,
                                                                vipStatus, INITIALIZE_ONLY, VIP_STATUS_PROGRAMMATICALLY);
    assertFalse(vipStatus.isInRotation());
    bootstrap.start();
    waitUntil(rpcServer::isRunning, "failed waiting for Rpc server running");
    waitUntil(() -> bootstrap.status() == StateMonitor.Status.up, "failed waiting for status 'up'");
    waitUntil(vipStatus::isInRotation, "failed waiting for server to be in rotation");

    bootstrap.deconstruct();
    assertEquals(StateMonitor.Status.down, bootstrap.status());
    assertFalse(rpcServer.isRunning());
    assertFalse(vipStatus.isInRotation());
}
 
Example 14
Source File: FlowChainLogServiceTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckIfThereIsEventInQueues() {
    List<FlowChainLog> flowChains = List.of(
            flowChainLog("1", true, 1L),
            flowChainLog("1", true, 2L),
            flowChainLog("2", true, 1L),
            flowChainLog("2", false, 2L)
    );
    assertTrue(underTest.hasEventInFlowChainQueue(flowChains));
}
 
Example 15
Source File: FutureUtilTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@Test
public void gatherIOShouldPropagateTimeoutAsIOException() throws IOException {
  var futures = List.of(completedFuture("foo"), future);
  exception.expect(IOException.class);
  exception.expectCause(instanceOf(TimeoutException.class));
  FutureUtil.gatherIO(futures, TIMED_OUT);
}
 
Example 16
Source File: MessageListenerThread.java    From core-ng-project with Apache License 2.0 4 votes vote down vote up
private <T> void handle(String topic, MessageProcess<T> process, List<ConsumerRecord<byte[], byte[]>> records, double longProcessThresholdInNano) {
    for (ConsumerRecord<byte[], byte[]> record : records) {
        ActionLog actionLog = logManager.begin("=== message handling begin ===");
        try {
            actionLog.action("topic:" + topic);
            actionLog.context("topic", topic);
            actionLog.context("handler", process.handler.getClass().getCanonicalName());
            actionLog.track("kafka", 0, 1, 0);

            Headers headers = record.headers();
            if ("true".equals(header(headers, MessageHeaders.HEADER_TRACE))) actionLog.trace = true;
            String correlationId = header(headers, MessageHeaders.HEADER_CORRELATION_ID);
            if (correlationId != null) actionLog.correlationIds = List.of(correlationId);
            String client = header(headers, MessageHeaders.HEADER_CLIENT);
            if (client != null) actionLog.clients = List.of(client);
            String refId = header(headers, MessageHeaders.HEADER_REF_ID);
            if (refId != null) actionLog.refIds = List.of(refId);
            logger.debug("[header] refId={}, client={}, correlationId={}", refId, client, correlationId);

            String key = key(record);
            actionLog.context("key", key);

            long timestamp = record.timestamp();
            logger.debug("[message] timestamp={}", timestamp);
            long lag = actionLog.date.toEpochMilli() - timestamp;
            actionLog.stat("consumer_lag_in_ms", lag);
            checkConsumerLag(lag, longConsumerLagThresholdInMs);

            byte[] value = record.value();
            logger.debug("[message] value={}", new BytesLogParam(value));
            T message = process.mapper.fromJSON(value);
            process.validator.validate(message, false);
            process.handler.handle(key, message);
        } catch (Throwable e) {
            logManager.logError(e);
        } finally {
            long elapsed = actionLog.elapsed();
            checkSlowProcess(elapsed, longProcessThresholdInNano);
            logManager.end("=== message handling end ===");
        }
    }
}
 
Example 17
Source File: AbstractDatabaseTest.java    From teku with Apache License 2.0 4 votes vote down vote up
protected void testShouldRecordFinalizedBlocksAndStates(
    final StateStorageMode storageMode,
    final boolean batchUpdate,
    Consumer<StateStorageMode> initializeDatabase)
    throws StateTransitionException {
  // Setup chains
  // Both chains share block up to slot 3
  final ChainBuilder primaryChain = ChainBuilder.create(VALIDATOR_KEYS);
  primaryChain.generateGenesis();
  primaryChain.generateBlocksUpToSlot(3);
  final ChainBuilder forkChain = primaryChain.fork();
  // Fork chain's next block is at 6
  forkChain.generateBlockAtSlot(6);
  forkChain.generateBlocksUpToSlot(7);
  // Primary chain's next block is at 7
  final SignedBlockAndState finalizedBlock = primaryChain.generateBlockAtSlot(7);
  final Checkpoint finalizedCheckpoint = getCheckpointForBlock(finalizedBlock.getBlock());
  final UnsignedLong pruneToSlot = finalizedCheckpoint.getEpochStartSlot();
  // Add some blocks in the next epoch
  final UnsignedLong hotSlot = pruneToSlot.plus(UnsignedLong.ONE);
  primaryChain.generateBlockAtSlot(hotSlot);
  forkChain.generateBlockAtSlot(hotSlot);

  // Setup database
  initializeDatabase.accept(storageMode);
  initGenesis();

  final Set<SignedBlockAndState> allBlocksAndStates =
      Streams.concat(primaryChain.streamBlocksAndStates(), forkChain.streamBlocksAndStates())
          .collect(Collectors.toSet());

  if (batchUpdate) {
    final StoreTransaction transaction = recentChainData.startStoreTransaction();
    add(transaction, allBlocksAndStates);
    justifyAndFinalizeEpoch(finalizedCheckpoint.getEpoch(), finalizedBlock, transaction);
    assertThat(transaction.commit()).isCompleted();
  } else {
    add(allBlocksAndStates);
    justifyAndFinalizeEpoch(finalizedCheckpoint.getEpoch(), finalizedBlock);
  }

  // Upon finalization, we should prune data
  final Set<Bytes32> blocksToPrune =
      Streams.concat(
              primaryChain.streamBlocksAndStates(0, pruneToSlot.longValue()),
              forkChain.streamBlocksAndStates(0, pruneToSlot.longValue()))
          .map(SignedBlockAndState::getRoot)
          .collect(Collectors.toSet());
  blocksToPrune.remove(finalizedBlock.getRoot());
  final Set<Checkpoint> checkpointsToPrune = Set.of(genesisCheckpoint);

  // Check data was pruned from store
  assertStoreWasPruned(store, blocksToPrune, checkpointsToPrune);

  restartStorage();

  // Check hot data
  final List<SignedBlockAndState> expectedHotBlocksAndStates =
      List.of(finalizedBlock, primaryChain.getBlockAndStateAtSlot(hotSlot));
  assertHotBlocksAndStates(store, expectedHotBlocksAndStates);
  final SignedBlockAndState prunedForkBlock = forkChain.getBlockAndStateAtSlot(hotSlot);
  assertThat(store.containsBlock(prunedForkBlock.getRoot())).isFalse();

  // Check finalized data
  final List<SignedBeaconBlock> expectedFinalizedBlocks =
      primaryChain
          .streamBlocksAndStates(0, 7)
          .map(SignedBlockAndState::getBlock)
          .collect(toList());
  assertBlocksFinalized(expectedFinalizedBlocks);
  assertGetLatestFinalizedRootAtSlotReturnsFinalizedBlocks(expectedFinalizedBlocks);
  assertBlocksAvailableByRoot(expectedFinalizedBlocks);
  assertFinalizedBlocksAvailableViaStream(
      1,
      3,
      primaryChain.getBlockAtSlot(1),
      primaryChain.getBlockAtSlot(2),
      primaryChain.getBlockAtSlot(3));

  switch (storageMode) {
    case ARCHIVE:
      // Finalized states should be available
      final Map<Bytes32, BeaconState> expectedStates =
          primaryChain
              .streamBlocksAndStates(0, 7)
              .collect(toMap(SignedBlockAndState::getRoot, SignedBlockAndState::getState));
      assertFinalizedStatesAvailable(expectedStates);
      break;
    case PRUNE:
      // Check pruned states
      final List<UnsignedLong> unavailableSlots =
          allBlocksAndStates.stream().map(SignedBlockAndState::getSlot).collect(toList());
      assertStatesUnavailable(unavailableSlots);
      break;
  }
}
 
Example 18
Source File: HijrahChronology.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
public List<Era> eras() {
    return List.of(HijrahEra.values());
}
 
Example 19
Source File: EmailGlobalUIConfig.java    From blackduck-alert with Apache License 2.0 4 votes vote down vote up
@Override
public List<ConfigField> createFields() {
    // Default fields
    ConfigField mailSmtpHost = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey(), LABEL_SMTP_HOST, JAVAMAIL_HOST_DESCRIPTION).applyRequired(true);
    ConfigField mailSmtpFrom = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_FROM_KEY.getPropertyKey(), LABEL_SMTP_FROM, JAVAMAIL_FROM_DESCRIPTION).applyRequired(true);
    ConfigField mailSmtpUser = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_USER_KEY.getPropertyKey(), LABEL_SMTP_USER, JAVAMAIL_USER_DESCRIPTION);
    ConfigField mailSmtpPassword = new PasswordConfigField(EmailPropertyKeys.JAVAMAIL_PASSWORD_KEY.getPropertyKey(), LABEL_SMTP_PASSWORD, JAVAMAIL_PASSWORD_DESCRIPTION, encryptionValidator);
    ConfigField mailSmtpAuth = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_KEY.getPropertyKey(), LABEL_SMTP_AUTH, JAVAMAIL_AUTH_DESCRIPTION)
                                   .applyRequiredRelatedField(mailSmtpUser.getKey())
                                   .applyRequiredRelatedField(mailSmtpPassword.getKey());

    // Advanced fields
    ConfigField mailSmtpPort = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_PORT_KEY.getPropertyKey(), LABEL_SMTP_PORT, JAVAMAIL_PORT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpConnectionTimeout = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_CONNECTION_TIMEOUT_KEY.getPropertyKey(), LABEL_SMTP_CONNECTION_TIMEOUT, JAVAMAIL_CONNECTION_TIMEOUT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpTimeout = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_TIMEOUT_KEY.getPropertyKey(), LABEL_SMTP_TIMEOUT, JAVAMAIL_TIMEOUT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpWriteTimeout = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_WRITETIMEOUT_KEY.getPropertyKey(), LABEL_SMTP_WRITE_TIMEOUT, JAVAMAIL_WRITETIMEOUT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpLocalhost = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_LOCALHOST_KEY.getPropertyKey(), LABEL_SMTP_LOCALHOST, JAVAMAIL_LOCALHOST_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpLocalAddress = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_LOCALHOST_ADDRESS_KEY.getPropertyKey(), LABEL_SMTP_LOCAL_ADDRESS, JAVAMAIL_LOCALHOST_ADDRESS_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpLocalPort = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_LOCALHOST_PORT_KEY.getPropertyKey(), LABEL_SMTP_LOCAL_PORT, JAVAMAIL_LOCALHOST_PORT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpEhlo = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey(), LABEL_SMTP_EHLO, JAVAMAIL_EHLO_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthMechanisms = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_MECHANISMS_KEY.getPropertyKey(), LABEL_SMTP_AUTH_MECHANISMS, JAVAMAIL_AUTH_MECHANISMS_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthLoginDisable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_LOGIN_DISABLE_KEY.getPropertyKey(), LABEL_SMTP_AUTH_LOGIN_DISABLE, JAVAMAIL_AUTH_LOGIN_DISABLE_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthPlainDisable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_LOGIN_PLAIN_DISABLE_KEY.getPropertyKey(), LABEL_SMTP_AUTH_PLAIN_DISABLE, JAVAMAIL_AUTH_LOGIN_PLAIN_DISABLE_DESCRIPTION)
                                               .applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthDigestMd5Disable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_DIGEST_MD5_DISABLE_KEY.getPropertyKey(), LABEL_SMTP_AUTH_DIGEST_MD5_DISABLE, JAVAMAIL_AUTH_DIGEST_MD5_DISABLE_DESCRIPTION)
                                                   .applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthNtlmDisable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_NTLM_DISABLE_KEY.getPropertyKey(), LABEL_SMTP_AUTH_NTLM_DISABLE, JAVAMAIL_AUTH_NTLM_DISABLE_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthNtlmDomain = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_NTLM_DOMAIN_KEY.getPropertyKey(), LABEL_SMTP_AUTH_NTLM_DOMAIN, JAVAMAIL_AUTH_NTLM_DOMAIN_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthNtlmFlags = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_NTLM_FLAGS_KEY.getPropertyKey(), LABEL_SMTP_AUTH_NTLM_FLAGS, JAVAMAIL_AUTH_NTLM_FLAGS_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAuthXoauth2Disable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_AUTH_XOAUTH2_DISABLE_KEY.getPropertyKey(), LABEL_SMTP_AUTH_XOAUTH2_DISABLE, JAVAMAIL_AUTH_XOAUTH2_DISABLE_DESCRIPTION)
                                                 .applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSubmitter = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_SUBMITTER_KEY.getPropertyKey(), LABEL_SMTP_SUBMITTER, JAVAMAIL_SUBMITTER_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpDnsNotify = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_DSN_NOTIFY_KEY.getPropertyKey(), LABEL_SMTP_DSN_NOTIFY, JAVAMAIL_DSN_NOTIFY_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpDnsRet = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_DSN_RET_KEY.getPropertyKey(), LABEL_SMTP_DSN_RET, JAVAMAIL_DSN_RET_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpAllow8bitmime = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_ALLOW_8_BITMIME_KEY.getPropertyKey(), LABEL_SMTP_ALLOW_8_BIT_MIME, JAVAMAIL_ALLOW_8_BITMIME_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSendPartial = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_SEND_PARTIAL_KEY.getPropertyKey(), LABEL_SMTP_SEND_PARTIAL, JAVAMAIL_SEND_PARTIAL_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSaslEnable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_SASL_ENABLE_KEY.getPropertyKey(), LABEL_SMTP_SASL_ENABLE, JAVAMAIL_SASL_ENABLE_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSaslMechanisms = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_SASL_MECHANISMS_KEY.getPropertyKey(), LABEL_SMTP_SASL_MECHANISMS, JAVAMAIL_SASL_MECHANISMS_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSaslAuthorizationId = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_SASL_AUTHORIZATION_ID_KEY.getPropertyKey(), LABEL_SMTP_SASL_AUTHORIZATION_ID, JAVAMAIL_SASL_AUTHORIZATION_ID_DESCRIPTION)
                                                  .applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSaslRealm = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_SASL_REALM_KEY.getPropertyKey(), LABEL_SMTP_SASL_REALM, JAVAMAIL_SASL_REALM_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSaslUseCanonicalHostname = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_SASL_USE_CANONICAL_HOSTNAME_KEY.getPropertyKey(), LABEL_SMTP_SASL_USE_CANONICAL_HOSTNAME,
        JAVAMAIL_SASL_USE_CANONICAL_HOSTNAME_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpQuitwait = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_QUITWAIT_KEY.getPropertyKey(), LABEL_SMTP_QUIT_WAIT, JAVAMAIL_QUITWAIT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpReportSuccess = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_REPORT_SUCCESS_KEY.getPropertyKey(), LABEL_SMTP_REPORT_SUCCESS, JAVAMAIL_REPORT_SUCCESS_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSslEnable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_SSL_ENABLE_KEY.getPropertyKey(), LABEL_SMTP_SSL_ENABLE, JAVAMAIL_SSL_ENABLE_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSslCheckServerIdentity = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_SSL_CHECKSERVERIDENTITY_KEY.getPropertyKey(), LABEL_SMTP_SSL_CHECK_SERVER_IDENTITY, JAVAMAIL_SSL_CHECKSERVERIDENTITY_DESCRIPTION)
                                                     .applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSslTrust = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_SSL_TRUST_KEY.getPropertyKey(), LABEL_SMTP_SSL_TRUST, JAVAMAIL_SSL_TRUST_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSslProtocols = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_SSL_PROTOCOLS_KEY.getPropertyKey(), LABEL_SMTP_SSL_PROTOCOLS, JAVAMAIL_SSL_PROTOCOLS_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSslCipherSuites = new TextInputConfigField
                                              (EmailPropertyKeys.JAVAMAIL_SSL_CIPHERSUITES_KEY.getPropertyKey(), LABEL_SMTP_SSL_CIPHER_SUITES, JAVAMAIL_SSL_CIPHERSUITES_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpStartTlsEnable = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_STARTTLS_ENABLE_KEY.getPropertyKey(), LABEL_SMTP_START_TLS_ENABLED, JAVAMAIL_STARTTLS_ENABLE_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpStartTlsRequired = new CheckboxConfigField
                                               (EmailPropertyKeys.JAVAMAIL_STARTTLS_REQUIRED_KEY.getPropertyKey(), LABEL_SMTP_START_TLS_REQUIRED, JAVAMAIL_STARTTLS_REQUIRED_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpProxyHost = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_PROXY_HOST_KEY.getPropertyKey(), LABEL_SMTP_PROXY_HOST, JAVAMAIL_PROXY_HOST_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpProxyPort = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_PROXY_PORT_KEY.getPropertyKey(), LABEL_SMTP_PROXY_PORT, JAVAMAIL_PROXY_PORT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSocksHost = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_SOCKS_HOST_KEY.getPropertyKey(), LABEL_SMTP_SOCKS_HOST, JAVAMAIL_SOCKS_HOST_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpSocksPort = new NumberConfigField(EmailPropertyKeys.JAVAMAIL_SOCKS_PORT_KEY.getPropertyKey(), LABEL_SMTP_SOCKS_PORT, JAVAMAIL_SOCKS_PORT_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpMailExtension = new TextInputConfigField(EmailPropertyKeys.JAVAMAIL_MAILEXTENSION_KEY.getPropertyKey(), LABEL_SMTP_MAIL_EXTENSION, JAVAMAIL_MAILEXTENSION_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpUserSet = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_USERSET_KEY.getPropertyKey(), LABEL_SMTP_USE_RSET, JAVAMAIL_USERSET_DESCRIPTION).applyPanel(ADVANCED_PANEL);
    ConfigField mailSmtpNoopStrict = new CheckboxConfigField(EmailPropertyKeys.JAVAMAIL_NOOP_STRICT_KEY.getPropertyKey(), LABEL_SMTP_NOOP_STRICT, JAVAMAIL_NOOP_STRICT_DESCRIPTION).applyPanel(ADVANCED_PANEL);

    return List.of(mailSmtpHost, mailSmtpFrom, mailSmtpAuth, mailSmtpUser, mailSmtpPassword, mailSmtpPort, mailSmtpConnectionTimeout, mailSmtpTimeout, mailSmtpWriteTimeout, mailSmtpLocalhost, mailSmtpLocalAddress,
        mailSmtpLocalPort, mailSmtpEhlo, mailSmtpAuthMechanisms, mailSmtpAuthLoginDisable, mailSmtpAuthPlainDisable, mailSmtpAuthDigestMd5Disable, mailSmtpAuthNtlmDisable, mailSmtpAuthNtlmDomain, mailSmtpAuthNtlmFlags,
        mailSmtpAuthXoauth2Disable, mailSmtpSubmitter, mailSmtpDnsNotify, mailSmtpDnsRet, mailSmtpAllow8bitmime, mailSmtpSendPartial, mailSmtpSaslEnable, mailSmtpSaslMechanisms, mailSmtpSaslAuthorizationId, mailSmtpSaslRealm,
        mailSmtpSaslUseCanonicalHostname, mailSmtpQuitwait, mailSmtpReportSuccess, mailSmtpSslEnable, mailSmtpSslCheckServerIdentity, mailSmtpSslTrust, mailSmtpSslProtocols, mailSmtpSslCipherSuites, mailSmtpStartTlsEnable,
        mailSmtpStartTlsRequired, mailSmtpProxyHost, mailSmtpProxyPort, mailSmtpSocksHost, mailSmtpSocksPort, mailSmtpMailExtension, mailSmtpUserSet, mailSmtpNoopStrict
    );
}
 
Example 20
Source File: VespaModelFactoryTest.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Test
public void hostedVespaZoneApplicationAllocatesNodesFromNodeRepo() {
    String hostName = "test-host-name";
    String routingClusterName = "routing-cluster";

    String hosts =
            "<?xml version='1.0' encoding='utf-8' ?>\n" +
                    "<hosts>\n" +
                    "  <host name='" + hostName + "'>\n" +
                    "    <alias>proxy1</alias>\n" +
                    "  </host>\n" +
                    "</hosts>";

    String services =
            "<?xml version='1.0' encoding='utf-8' ?>\n" +
                    "<services version='1.0' xmlns:deploy='vespa'>\n" +
                    "    <admin version='2.0'>\n" +
                    "        <adminserver hostalias='proxy1' />\n" +
                    "    </admin>" +
                    "    <container id='" + routingClusterName + "' version='1.0'>\n" +
                    "        <nodes type='proxy'/>\n" +
                    "    </container>\n" +
                    "</services>";

    HostProvisioner provisionerToOverride = new HostProvisioner() {
        @Override
        public HostSpec allocateHost(String alias) {
            return new HostSpec(hostName,
                                NodeResources.unspecified(), NodeResources.unspecified(), NodeResources.unspecified(),
                                ClusterMembership.from(ClusterSpec.request(ClusterSpec.Type.admin, new ClusterSpec.Id(routingClusterName)).vespaVersion("6.42").build(), 0),
                                Optional.empty(), Optional.empty(), Optional.empty());
        }

        @Override
        public List<HostSpec> prepare(ClusterSpec cluster, Capacity capacity, ProvisionLogger logger) {
            return List.of(new HostSpec(hostName,
                                        NodeResources.unspecified(), NodeResources.unspecified(), NodeResources.unspecified(),
                                        ClusterMembership.from(ClusterSpec.request(ClusterSpec.Type.container, new ClusterSpec.Id(routingClusterName)).vespaVersion("6.42").build(), 0),
                                        Optional.empty(), Optional.empty(), Optional.empty()));
        }
    };

    ModelContext modelContext = createMockModelContext(hosts, services, provisionerToOverride);
    Model model = new VespaModelFactory(new NullConfigModelRegistry()).createModel(modelContext);

    List<HostInfo> allocatedHosts = new ArrayList<>(model.getHosts());
    assertThat(allocatedHosts.size(), is(1));
    HostInfo hostInfo = allocatedHosts.get(0);

    assertThat(hostInfo.getHostname(), is(hostName));
    assertTrue("Routing service should run on host " + hostName,
               hostInfo.getServices().stream()
                       .map(ServiceInfo::getConfigId)
                       .anyMatch(configId -> configId.contains(routingClusterName)));
}