TupleSchema { public Tuple makeWith(Object...values) { return make(values); } private  TupleSchema(String name, TupleSlot[] slots, Map<String, Integer> slotLookup); static TupleSchema of(String name, TupleSlot...slots); String getName(); Tuple makeWith(Object...values); Tuple make(Object[] values); Tuple make(TupleKeyValue...keyValues); Tuple make(NamedValue...builders); Tuple make(Map<String, Object> values); Tuple deserialise(BiFunction<V, Type, Object> deserialiser, Map<String, V> values); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); TupleKey<Optional<T>> getOptionalKey(String name, Class<T> valueType); TupleKey<List<T>> getListKey(String name, Class<T> elementType); TupleKey<Map<K, V>> getMapKey(String name, Class<K> keyType, Class<V> valueType); TupleKey<T> getKey(String name, Type type);  }
@Test(expected=IllegalArgumentException.class) public void validatesValueCountWhenCreatingTuples() { coordinateSchema.makeWith(1, 2, 3); }
@Test(expected=IllegalArgumentException.class) public void validatesValueTypesWhenCreatingTuples() { coordinateSchema.makeWith(1, 12.5); }
@Test public void describesAllTypeMismatches() { try { coordinateSchema.makeWith("p", 12.5); fail("Should throw exception"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), equalTo("Slot (x: java.lang.Integer) does not accept value <p>, " + "Slot (y: java.lang.Integer) does not accept value <12.5>")); } }