RankableObjectWithFields implements Rankable, Serializable { public List<Object> getFields() { return fields; } RankableObjectWithFields(Object obj, long count, Object... otherFields); static RankableObjectWithFields from(Tuple tuple); @Override Object getObject(); @Override long getCount(); List<Object> getFields(); @Override int compareTo(Rankable other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override Rankable copy();  }
@Test(dataProvider = "fieldsData") public void shouldReturnTheFields(Object obj, long count, Object[] fields) { RankableObjectWithFields r = new RankableObjectWithFields(obj, count, fields); List<Object> actualFields = r.getFields(); assertThat(actualFields).isEqualTo(Lists.newArrayList(fields)); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void fieldsShouldBeImmutable() { RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT, ANY_FIELD); List<Object> fields = r.getFields(); fields.remove(0); }