Java Code Examples for com.google.cloud.datastore.StringValue#of()

The following examples show how to use com.google.cloud.datastore.StringValue#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: UpperCaseStringIndexer.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Override
public Value<?> index(Value<?> input) {
  if (input.getType() == ValueType.NULL) {
    return NullValue.of();
  }
  try {
    String str = ((StringValue) input).get();
    return StringValue.of(str.toUpperCase(Locale.ENGLISH));
  } catch (Exception exp) {
    throw new IndexingException(exp);
  }
}
 
Example 2
Source File: LowerCaseStringIndexer.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Override
public Value<?> index(Value<?> input) {
  if (input.getType() == ValueType.NULL) {
    return NullValue.of();
  }
  try {
    String str = ((StringValue) input).get();
    return StringValue.of(str.toLowerCase(Locale.ENGLISH));
  } catch (Exception exp) {
    throw new IndexingException(exp);
  }
}
 
Example 3
Source File: LowerCaseStringIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testIndex_2() {
  StringValue input = StringValue.of("Hello World");
  StringValue output = (StringValue) indexer.index(input);
  assertEquals(input.get().toLowerCase(Locale.ENGLISH), output.get());
  assertNotEquals(input.get(), output.get());
}
 
Example 4
Source File: UpperCaseStringIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testIndex_2() {
  StringValue input = StringValue.of("Hello World!");
  StringValue output = (StringValue) indexer.index(input);
  assertEquals(input.get().toUpperCase(Locale.ENGLISH), output.get());
  assertNotEquals(input.get(), output.get());
}
 
Example 5
Source File: UpperCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testIndex_2() {
  Value<?>[] inputArray = { StringValue.of("ONE"), StringValue.of("Two"),
      StringValue.of("thRee") };
  ListValue input = ListValue.of(Arrays.asList(inputArray));
  ListValue output = (ListValue) indexer.index(input);
  List<StringValue> inputList = (List<StringValue>) input.get();
  List<StringValue> outputList = (List<StringValue>) output.get();
  assertEquals(inputList.get(0).get().toUpperCase(Locale.ENGLISH), outputList.get(0).get());
  assertEquals(inputList.get(1).get().toUpperCase(Locale.ENGLISH), outputList.get(1).get());
  assertEquals(inputList.get(2).get().toUpperCase(Locale.ENGLISH), outputList.get(2).get());
}
 
Example 6
Source File: UpperCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testIndex_3() {
  Value<?>[] inputArray = { StringValue.of("Hello"), NullValue.of() };
  ListValue input = ListValue.of(Arrays.asList(inputArray));
  ListValue output = (ListValue) indexer.index(input);
  List<? extends Value> inputList = input.get();
  List<? extends Value> outputList = output.get();
  assertEquals(((StringValue) inputList.get(0)).get().toUpperCase(Locale.ENGLISH),
      outputList.get(0).get());
  assertEquals(inputList.get(1).get(), outputList.get(1).get());
}
 
Example 7
Source File: UpperCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = IndexingException.class)
public void testIndex_4() {
  StringValue input = StringValue.of("Hello World");
  try {
    Value<?> output = indexer.index(input);
  } catch (Exception exp) {
    LOGGER.log(Level.INFO, exp.toString());
    throw exp;
  }
}
 
Example 8
Source File: UpperCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = IndexingException.class)
public void testIndex_5() {
  Value<?>[] inputArray = { StringValue.of("Hello"), NullValue.of(), LongValue.of(5L) };
  ListValue input = ListValue.of(Arrays.asList(inputArray));
  try {
    ListValue output = (ListValue) indexer.index(input);
  } catch (Exception exp) {
    LOGGER.log(Level.INFO, exp.toString());
    throw exp;
  }
}
 
Example 9
Source File: LowerCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testIndex_2() {
  Value<?>[] inputArray = { StringValue.of("ONE"), StringValue.of("Two"),
      StringValue.of("thRee") };
  ListValue input = ListValue.of(Arrays.asList(inputArray));
  ListValue output = (ListValue) indexer.index(input);
  List<StringValue> inputList = (List<StringValue>) input.get();
  List<StringValue> outputList = (List<StringValue>) output.get();
  assertEquals(inputList.get(0).get().toLowerCase(Locale.ENGLISH), outputList.get(0).get());
  assertEquals(inputList.get(1).get().toLowerCase(Locale.ENGLISH), outputList.get(1).get());
  assertEquals(inputList.get(2).get().toLowerCase(Locale.ENGLISH), outputList.get(2).get());
}
 
Example 10
Source File: LowerCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testIndex_3() {
  Value<?>[] inputArray = { StringValue.of("Hello"), NullValue.of() };
  ListValue input = ListValue.of(Arrays.asList(inputArray));
  ListValue output = (ListValue) indexer.index(input);
  List<? extends Value> inputList = input.get();
  List<? extends Value> outputList = output.get();
  assertEquals(((StringValue) inputList.get(0)).get().toLowerCase(Locale.ENGLISH),
      outputList.get(0).get());
  assertEquals(inputList.get(1).get(), outputList.get(1).get());
}
 
Example 11
Source File: LowerCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = IndexingException.class)
public void testIndex_4() {
  StringValue input = StringValue.of("Hello World");
  try {
    Value<?> output = indexer.index(input);
  } catch (Exception exp) {
    LOGGER.log(Level.INFO, exp.toString());
    throw exp;
  }
}
 
Example 12
Source File: LowerCaseStringListIndexerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = IndexingException.class)
public void testIndex_5() {
  Value<?>[] inputArray = { StringValue.of("Hello"), NullValue.of(), LongValue.of(5L) };
  ListValue input = ListValue.of(Arrays.asList(inputArray));
  try {
    ListValue output = (ListValue) indexer.index(input);
  } catch (Exception exp) {
    LOGGER.log(Level.INFO, exp.toString());
    throw exp;
  }
}
 
Example 13
Source File: ZonedDateTimeMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = MappingException.class)
public void testToModel2() {
  StringValue v = StringValue.of("Hello");
  ZonedDateTimeMapper mapper = new ZonedDateTimeMapper();
  try {
    mapper.toModel(v);
  } catch (MappingException e) {
    e.printStackTrace();
    throw e;
  }
}
 
Example 14
Source File: OffsetDateTimeMapperTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test(expected = MappingException.class)
public void testToModel2() {
  StringValue v = StringValue.of("Hello");
  OffsetDateTimeMapper mapper = new OffsetDateTimeMapper();
  try {
    mapper.toModel(v);
  } catch (MappingException e) {
    e.printStackTrace();
    throw e;
  }
}