scala.collection.immutable.List Java Examples

The following examples show how to use scala.collection.immutable.List. 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: ParserLogicalTest.java    From odata with Apache License 2.0 6 votes vote down vote up
private void processQueryFunction(FilterOption option, String boolMethod) {
    BooleanMethodCallExpr methodCall = (BooleanMethodCallExpr) option.expression();
    assertThat(methodCall.methodName(), is(boolMethod));
    List<Expression> args = methodCall.args();
    Iterator iterator = args.iterator();
    while (iterator.hasNext()) {
        Object cursor = iterator.next();
        if (cursor instanceof EntityPathExpr) {
            EntityPathExpr pathExpr = (EntityPathExpr) cursor;
            PropertyPathExpr path = (PropertyPathExpr) pathExpr.subPath().get();
            assertThat(path.propertyName(), is("name"));
        } else if (cursor instanceof LiteralExpr) {
            LiteralExpr literalExpr = (LiteralExpr) cursor;
            StringLiteral stringLiteral = (StringLiteral) literalExpr.value();
            assertThat(stringLiteral.value(), is("John"));
        }
    }
}
 
Example #2
Source File: ParserQueryFunctionsTest.java    From odata with Apache License 2.0 6 votes vote down vote up
private void testQueryFunction(String operator) throws ODataException {
    EqExpr expr = getExprFromOperator(operator);
    MethodCallExpr call = (MethodCallExpr) expr.left();
    assertThat(call.methodName(), is(operator));
    List<Expression> args = call.args();
    Iterator iter = args.iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof EntityPathExpr) {
            EntityPathExpr entityPathExpr = (EntityPathExpr) obj;
            PropertyPathExpr propertyPath = (PropertyPathExpr) entityPathExpr.subPath().get();
            assertThat(propertyPath.propertyName(), is("name"));
        }
    }
    LiteralExpr literal = (LiteralExpr) expr.right();
    NumberLiteral number = (NumberLiteral) literal.value();
    assertThat(number.value(), is(new BigDecimal(new java.math.BigDecimal(19))));
}
 
Example #3
Source File: OstrichAdminService.java    From terrapin with Apache License 2.0 6 votes vote down vote up
public void start() {
  Duration[] defaultLatchIntervals = {Duration.apply(1, TimeUnit.MINUTES)};
  @SuppressWarnings("deprecation")
  AdminServiceFactory adminServiceFactory = new AdminServiceFactory(
      this.mPort,
      20,
      List$.MODULE$.<StatsFactory>empty(),
      Option.<String>empty(),
      List$.MODULE$.<Regex>empty(),
      Map$.MODULE$.<String, CustomHttpHandler>empty(),
      List.<Duration>fromArray(defaultLatchIntervals));
  RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironment(this);
  AdminHttpService service = adminServiceFactory.apply(runtimeEnvironment);
  for (Map.Entry<String, CustomHttpHandler> entry: this.mCustomHttpHandlerMap.entrySet()) {
    service.httpServer().createContext(entry.getKey(), entry.getValue());
  }
}
 
Example #4
Source File: OstrichAdminService.java    From pinlater with Apache License 2.0 6 votes vote down vote up
public void start() {
  Duration[] defaultLatchIntervals = {Duration.apply(1, TimeUnit.MINUTES)};
  @SuppressWarnings("deprecation")
  AdminServiceFactory adminServiceFactory = new AdminServiceFactory(
      this.mPort,
      20,
      List$.MODULE$.<StatsFactory>empty(),
      Option.<String>empty(),
      List$.MODULE$.<Regex>empty(),
      Map$.MODULE$.<String, CustomHttpHandler>empty(),
      List.<Duration>fromArray(defaultLatchIntervals));
  RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironment(this);
  AdminHttpService service = adminServiceFactory.apply(runtimeEnvironment);
  for (Map.Entry<String, CustomHttpHandler> entry : this.mCustomHttpHandlerMap.entrySet()) {
    service.httpServer().createContext(entry.getKey(), entry.getValue());
  }
}
 
Example #5
Source File: UserProfileEigenModelerTest.java    From Eagle with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testBuild() throws Exception {

    UserProfileEigenModeler modeler = new UserProfileEigenModeler();
    String user = "user1";
    final RealMatrix mockMatrix = new Array2DRowRealMatrix(buildMockData());
    List<UserProfileEigenModel> model = modeler.build("default",user, mockMatrix);
    Assert.assertEquals(model.length(), 1);

    UserProfileEigenModel eigenModel = model.head();
    Assert.assertNotNull(eigenModel.statistics());
    Assert.assertNotNull(eigenModel.principalComponents());
    Assert.assertNotNull(eigenModel.maxVector());
    Assert.assertNotNull(eigenModel.minVector());
    Assert.assertEquals(eigenModel.statistics().length, mockMatrix.getColumnDimension());
    Assert.assertTrue(eigenModel.principalComponents().length <= mockMatrix.getColumnDimension());
    Assert.assertTrue(eigenModel.maxVector().getDimension() <= mockMatrix.getColumnDimension());
    Assert.assertTrue(eigenModel.minVector().getDimension() <= mockMatrix.getColumnDimension());
    Assert.assertEquals(true, eigenModel.statistics()[3].isLowVariant());
}
 
Example #6
Source File: SylphKafkaOffset.java    From sylph with Apache License 2.0 5 votes vote down vote up
@Override
public List<DStream<?>> dependencies()
{
    return List$.MODULE$.<DStream<?>>newBuilder()
            .$plus$eq(parent)
            .result();
}
 
Example #7
Source File: CucumberReportAdapterTest.java    From openCypher with Apache License 2.0 5 votes vote down vote up
@Override
public Either<ExecutionFailed, CypherValueRecords> cypher(String query, Map<String, CypherValue> params, QueryType meta) {
    if (query.contains("foo()")) {
        return new Left<>(new ExecutionFailed("SyntaxError", "compile time", "UnknownFunction", null));
    } else if (query.startsWith("RETURN ")) {
        String result = query.replace("RETURN ", "");
        System.out.println("Producing some output " + result);
        List<String> header = new Set.Set1<>(result).toList();
        Map<String, String> row = new Map.Map1<>(result, result);
        List<Map<String, String>> rows = new Set.Set1<>(row).toList();
        return new Right<>(new StringRecords(header, rows).asValueRecords());
    } else {
        return new Right<>(CypherValueRecords.empty());
    }
}
 
Example #8
Source File: ExpressionParserTest.java    From odata with Apache License 2.0 5 votes vote down vote up
@Test
public void testEntitySetRootElement() {
    ODataUriParser parser = new ODataUriParser(model);
    ODataUri target = parser.parseUri(SERVICE_ROOT + "Customers?$filter=Phone eq $root/Customers('A1245')/Phone");

    assertThat(target.serviceRoot() + "/", is(SERVICE_ROOT));

    ResourcePathUri resourcePathUri = (ResourcePathUri) target.relativeUri();

    List<QueryOption> options = resourcePathUri.options();
    assertThat(options.size(), is(1));

    Iterator<QueryOption> iter = options.iterator();

    while (iter.hasNext()) {
        Object obj = iter.next();
        if (obj instanceof FilterOption) {
            FilterOption option = (FilterOption) obj;

            EqExpr expr = (EqExpr) option.expression();
            EntityPathExpr pathExpr = (EntityPathExpr) expr.left();
            Option<PathExpr> subPath = pathExpr.subPath();
            PropertyPathExpr propertyPath = (PropertyPathExpr) subPath.get();

            assertThat(propertyPath.propertyName(), is(notNullValue()));
            assertThat(propertyPath.propertyName(), is("Phone"));

            EntitySetRootExpr rootExpr = (EntitySetRootExpr) expr.right();
            assertThat(rootExpr.entitySetName(), is("Customers"));

            SimpleKeyPredicate predicate = (SimpleKeyPredicate) rootExpr.keyPredicate();
            StringLiteral value = (StringLiteral) predicate.value();
            assertThat(value.value(), is("A1245"));

        }
    }
}
 
Example #9
Source File: SASLClusterTestHarness.java    From kcache with Apache License 2.0 5 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
    // Important if tests leak consumers, producers or brokers.
    LoginManager.closeAll();

    File serverKeytab = File.createTempFile("server-", ".keytab");
    File clientKeytab = File.createTempFile("client-", ".keytab");

    // create a JAAS file.
    Option<File> serverKeytabOption = Option.apply(serverKeytab);
    Option<File> clientKeytabOption = Option.apply(clientKeytab);
    List<String> serverSaslMechanisms = JavaConversions.asScalaBuffer(Arrays.asList("GSSAPI")).toList();
    Option<String> clientSaslMechanism = Option.apply("GSSAPI");

    java.util.List<JaasTestUtils.JaasSection> jaasSections = new ArrayList<>();
    jaasSections.add(JaasTestUtils.kafkaServerSection(JaasTestUtils.KafkaServerContextName(), serverSaslMechanisms, serverKeytabOption));
    jaasSections.add(JaasTestUtils.kafkaClientSection(clientSaslMechanism, clientKeytabOption));
    jaasSections.addAll(JavaConversions.asJavaCollection(JaasTestUtils.zkSections()));
    String jaasFilePath = JaasTestUtils.writeJaasContextsToFile(JavaConversions.asScalaBuffer(jaasSections).toSeq()).getAbsolutePath();

    log.info("Using KDC home: " + kdcHome.getAbsolutePath());
    kdc = new MiniKdc(kdcProps, kdcHome);
    kdc.start();

    createPrincipal(serverKeytab, "kafka/localhost");
    createPrincipal(clientKeytab, "client");
    createPrincipal(clientKeytab, "client2");

    // This will cause a reload of the Configuration singleton when `getConfiguration` is called.
    Configuration.setConfiguration(null);

    System.setProperty(JAAS_CONF, jaasFilePath);
    System.setProperty(ZK_AUTH_PROVIDER, "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
    super.setUp();
}
 
Example #10
Source File: SwaggerInitializer.java    From micro-server with Apache License 2.0 5 votes vote down vote up
public void contextInitialized(ServletContextEvent servletContextEvent) {
	BeanConfig beanConfig = new BeanConfig() {
		@Override
		public List<Class<?>> classesFromContext(Application app, ServletConfig sc) {
			return resourceClasses;
		}
	};
	beanConfig.setVersion("1.0.2");
	beanConfig.setBasePath(baseUrlPattern);
	beanConfig.setDescription("RESTful resources");
	beanConfig.setTitle("RESTful API");
	beanConfig.setScan(true);
}
 
Example #11
Source File: ScalaFeelEngine.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected List<CustomValueMapper> getValueMappers() {
  SpinValueMapperFactory spinValueMapperFactory = new SpinValueMapperFactory();

  CustomValueMapper javaValueMapper = new JavaValueMapper();

  CustomValueMapper spinValueMapper = spinValueMapperFactory.createInstance();
  if (spinValueMapper != null) {
    return toScalaList(javaValueMapper, spinValueMapper);

  } else {
    return toScalaList(javaValueMapper);

  }
}
 
Example #12
Source File: JavaUserProfileModeler.java    From Eagle with Apache License 2.0 5 votes vote down vote up
@Override
public List<M> build(String site, String user, RealMatrix matrix) {
    java.util.List<M> models = generate(site, user, matrix);
    if (models != null) {
        return JavaConversions.asScalaIterable(models).toList();
    } else {
        return null;
    }
}
 
Example #13
Source File: KafkaPartitionLevelConsumerTest.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Override
public TopicMetadataResponse send(TopicMetadataRequest request) {
  java.util.List<String> topics = request.topics();
  TopicMetadata[] topicMetadataArray = new TopicMetadata[topics.size()];

  for (int i = 0; i < topicMetadataArray.length; i++) {
    String topic = topics.get(i);
    if (!topic.equals(topicName)) {
      topicMetadataArray[i] = new TopicMetadata(topic, null, Errors.UNKNOWN_TOPIC_OR_PARTITION.code());
    } else {
      PartitionMetadata[] partitionMetadataArray = new PartitionMetadata[partitionCount];
      for (int j = 0; j < partitionCount; j++) {
        java.util.List<BrokerEndPoint> emptyJavaList = Collections.emptyList();
        List<BrokerEndPoint> emptyScalaList = JavaConversions.asScalaBuffer(emptyJavaList).toList();
        partitionMetadataArray[j] =
            new PartitionMetadata(j, Some.apply(brokerArray[partitionLeaderIndices[j]]), emptyScalaList,
                emptyScalaList, Errors.NONE.code());
      }

      Seq<PartitionMetadata> partitionsMetadata = List.fromArray(partitionMetadataArray);
      topicMetadataArray[i] = new TopicMetadata(topic, partitionsMetadata, Errors.NONE.code());
    }
  }

  Seq<BrokerEndPoint> brokers = List.fromArray(brokerArray);
  Seq<TopicMetadata> topicsMetadata = List.fromArray(topicMetadataArray);

  return new TopicMetadataResponse(new kafka.api.TopicMetadataResponse(brokers, topicsMetadata, -1));
}
 
Example #14
Source File: ScalaFeelEngine.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected <T> List<T> toList(java.util.List list) {
  return ListHasAsScala(list).asScala().toList();
}
 
Example #15
Source File: ScalaFeelEngine.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@SafeVarargs
protected final <T> List<T> toScalaList(T... elements) {
  java.util.List<T> listAsJava = Arrays.asList(elements);

  return toList(listAsJava);
}
 
Example #16
Source File: SparkSocketStream.java    From incubator-retired-mrql with Apache License 2.0 4 votes vote down vote up
@Override
public List dependencies () {
    return Nil$.MODULE$;
}
 
Example #17
Source File: SparkFileInputStream.java    From incubator-retired-mrql with Apache License 2.0 4 votes vote down vote up
@Override
public List dependencies () {
    return Nil$.MODULE$;
}
 
Example #18
Source File: ParserTestSuite.java    From odata with Apache License 2.0 4 votes vote down vote up
public FilterOption getSingleOption(ODataUri oDataUri) {
    ResourcePathUri relative = (ResourcePathUri) oDataUri.relativeUri();
    List<QueryOption> options = relative.options();
    assertThat(options.size(), is(1));
    return (FilterOption) options.head();
}
 
Example #19
Source File: ScalaFeelEngine.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
public ScalaFeelEngine(java.util.List<FeelCustomFunctionProvider> functionProviders) {
  List<CustomValueMapper> valueMappers = getValueMappers();

  CompositeValueMapper compositeValueMapper = new CompositeValueMapper(valueMappers);

  CustomFunctionTransformer customFunctionTransformer =
    new CustomFunctionTransformer(functionProviders, compositeValueMapper);

  feelEngine = buildFeelEngine(customFunctionTransformer, compositeValueMapper);
}
 
Example #20
Source File: JavaUserProfileModeler.java    From Eagle with Apache License 2.0 2 votes vote down vote up
/**
 * Java delegate method for {@code eagle.security.userprofile.model.JavaUserProfileModeler#build(String site, String user, RealMatrix matrix)}
 *
 * @param site eagle site
 * @param user eagle user
 * @param matrix user activity matrix
 * @return Generate user profile model
 */
public abstract java.util.List<M> generate(String site, String user, RealMatrix matrix);