CoderProperties.encode
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.apache.beam.sdk.testing.CoderProperties.encode(Showing top 12 results out of 315)

origin: apache/beam

@Test
public void testClosingCoderFailsWhenEncoding() throws Exception {
 expectedException.expect(UnsupportedOperationException.class);
 expectedException.expectMessage("Caller does not own the underlying");
 CoderProperties.encode(new ClosingCoder(), Context.NESTED, "test-value");
}
origin: apache/beam

@Test
public void testCoderWhichConsumesMoreBytesThanItProducesFail() throws IOException {
 try {
  BadCoderThatConsumesMoreBytes coder = new BadCoderThatConsumesMoreBytes();
  byte[] bytes = CoderProperties.encode(coder, Context.NESTED, "TestData");
  CoderProperties.decode(coder, Context.NESTED, bytes);
  Assert.fail("Expected Assertion Error");
 } catch (AssertionError error) {
  assertThat(error.getMessage(),
    CoreMatchers.containsString("consumed bytes equal to encoded bytes"));
 }
}
origin: apache/beam

/**
 * Verifies that for the given {@code Coder<T>}, {@code Coder.Context}, and
 * values of type {@code T}, the values are equal if and only if the
 * encoded bytes are equal, in any {@code Coder.Context}.
 */
public static <T> void coderConsistentWithEqualsInContext(
  Coder<T> coder, Coder.Context context, T value1, T value2) throws Exception {
 assertEquals(
   value1.equals(value2),
   Arrays.equals(
     encode(coder, context, value1),
     encode(coder, context, value2)));
}
origin: apache/beam

private static <T> T decodeEncode(Coder<T> coder, Coder.Context context, T value)
  throws CoderException, IOException {
 return decode(coder, context, encode(coder, context, value));
}
origin: apache/beam

/**
 * Verifies that for the given {@code Coder<T>}, {@code Coder.Context}, and values of
 * type {@code T}, if the values are equal then the encoded bytes are equal.
 */
public static <T> void coderDeterministicInContext(
  Coder<T> coder, Coder.Context context, T value1, T value2)
  throws Exception {
 try {
  coder.verifyDeterministic();
 } catch (NonDeterministicException e) {
  fail("Expected that the coder is deterministic");
 }
 assertThat("Expected that the passed in values are equal()", value1, equalTo(value2));
 assertThat(
   encode(coder, context, value1),
   equalTo(encode(coder, context, value2)));
}
origin: apache/beam

/**
 * Verifies that for the given {@code Coder<T>}, {@code Coder.Context}, and
 * values of type {@code T}, the structural values are equal if and only if the
 * encoded bytes are equal, in any {@code Coder.Context}.
 */
public static <T> void structuralValueConsistentWithEqualsInContext(
  Coder<T> coder, Coder.Context context, T value1, T value2) throws Exception {
 assertEquals(
   coder.structuralValue(value1).equals(coder.structuralValue(value2)),
   Arrays.equals(
     encode(coder, context, value1),
     encode(coder, context, value2)));
}
origin: org.apache.beam/beam-sdks-java-core

@Test
public void testClosingCoderFailsWhenEncoding() throws Exception {
 expectedException.expect(UnsupportedOperationException.class);
 expectedException.expectMessage("Caller does not own the underlying");
 CoderProperties.encode(new ClosingCoder(), Context.NESTED, "test-value");
}
origin: org.apache.beam/beam-sdks-java-core

@Test
public void testCoderWhichConsumesMoreBytesThanItProducesFail() throws IOException {
 try {
  BadCoderThatConsumesMoreBytes coder = new BadCoderThatConsumesMoreBytes();
  byte[] bytes = CoderProperties.encode(coder, Context.NESTED, "TestData");
  CoderProperties.decode(coder, Context.NESTED, bytes);
  Assert.fail("Expected Assertion Error");
 } catch (AssertionError error) {
  assertThat(error.getMessage(),
    CoreMatchers.containsString("consumed bytes equal to encoded bytes"));
 }
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * Verifies that for the given {@code Coder<T>}, {@code Coder.Context}, and
 * values of type {@code T}, the structural values are equal if and only if the
 * encoded bytes are equal, in any {@code Coder.Context}.
 */
public static <T> void structuralValueConsistentWithEqualsInContext(
  Coder<T> coder, Coder.Context context, T value1, T value2) throws Exception {
 assertEquals(
   coder.structuralValue(value1).equals(coder.structuralValue(value2)),
   Arrays.equals(
     encode(coder, context, value1),
     encode(coder, context, value2)));
}
origin: org.apache.beam/beam-sdks-java-core

private static <T> T decodeEncode(Coder<T> coder, Coder.Context context, T value)
  throws CoderException, IOException {
 return decode(coder, context, encode(coder, context, value));
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * Verifies that for the given {@code Coder<T>}, {@code Coder.Context}, and
 * values of type {@code T}, the values are equal if and only if the
 * encoded bytes are equal, in any {@code Coder.Context}.
 */
public static <T> void coderConsistentWithEqualsInContext(
  Coder<T> coder, Coder.Context context, T value1, T value2) throws Exception {
 assertEquals(
   value1.equals(value2),
   Arrays.equals(
     encode(coder, context, value1),
     encode(coder, context, value2)));
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * Verifies that for the given {@code Coder<T>}, {@code Coder.Context}, and values of
 * type {@code T}, if the values are equal then the encoded bytes are equal.
 */
public static <T> void coderDeterministicInContext(
  Coder<T> coder, Coder.Context context, T value1, T value2)
  throws Exception {
 try {
  coder.verifyDeterministic();
 } catch (NonDeterministicException e) {
  fail("Expected that the coder is deterministic");
 }
 assertThat("Expected that the passed in values are equal()", value1, equalTo(value2));
 assertThat(
   encode(coder, context, value1),
   equalTo(encode(coder, context, value2)));
}
org.apache.beam.sdk.testingCoderPropertiesencode

Popular methods of CoderProperties

  • coderDecodeEncodeEqual
    Verifies that for the given Coder, and value of type T, encoding followed by decoding yields an equa
  • coderSerializable
    Verifies that the given Coder can be correctly serialized and deserialized.
  • coderEncodesBase64
  • coderDecodeEncodeContentsInSameOrder
    Verifies that for the given Coder>, and value of type Collection, encoding followed by decoding yiel
  • structuralValueDecodeEncodeEqual
    Verifies that for the given Coder and value of type T, the structural value is equal to the structur
  • coderConsistentWithEquals
    Verifies that for the given Coder and values of type T, the values are equal if and only if the enco
  • coderDecodeEncodeContentsEqual
    Verifies that for the given Coder>, and value of type Collection, encoding followed by decoding yiel
  • coderDecodeEncodeEqualInContext
    Verifies that for the given Coder, Coder.Context, and value of type T, encoding followed by decoding
  • coderDecodesBase64ContentsEqual
  • coderDeterministic
    Verifies that for the given Coder, and values of type T, if the values are equal then the encoded by
  • decode
  • coderConsistentWithEqualsInContext
    Verifies that for the given Coder, Coder.Context, and values of type T, the values are equal if and
  • decode,
  • coderConsistentWithEqualsInContext,
  • coderDecodeEncodeContentsEqualInContext,
  • coderDecodeEncodeContentsInSameOrderInContext,
  • coderDecodesBase64,
  • coderDeterministicInContext,
  • decodeEncode,
  • structuralValueConsistentWithEquals,
  • structuralValueConsistentWithEqualsInContext

Popular classes and methods

  • getApplicationContext (Context)
  • setRequestProperty (URLConnection)
    Sets the value of the specified request header field. The value will only be used by the current URL
  • compareTo (BigDecimal)
    Compares this BigDecimal with val. Returns one of the three values 1, 0, or -1. The method behaves a
  • Proxy (java.net)
    This class represents a proxy setting, typically a type (http, socks) and a socket address. A Proxy
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)