### Question:
DefaultKeySizeConstraint implements Constraint { @Override public List<Short> check(Environment env, Mutation mutation) { if (mutation.numBytes() < maxSize) return NO_VIOLATIONS; List<Short> violations = new ArrayList<>(); for (ColumnUpdate cu : mutation.getUpdates()) { int size = mutation.getRow().length; size += cu.getColumnFamily().length; size += cu.getColumnQualifier().length; size += cu.getColumnVisibility().length; if (size > maxSize) violations.add(MAX__KEY_SIZE_EXCEEDED_VIOLATION); } return violations; }  @Override String getViolationDescription(short violationCode); @Override List<Short> check(Environment env, Mutation mutation);  }### Answer:
@Test public void testConstraint() { Mutation m = new Mutation("rowId"); m.put("colf", "colq", new Value(new byte[] {})); assertEquals(Collections.emptyList(), constraint.check(null, m)); m = new Mutation(oversized); m.put("colf", "colq", new Value(new byte[] {})); assertEquals( Collections.singletonList(DefaultKeySizeConstraint.MAX__KEY_SIZE_EXCEEDED_VIOLATION), constraint.check(null, m)); m = new Mutation("rowid"); m.put(new Text(oversized), new Text("colq"), new Value(new byte[] {})); assertEquals( Collections.singletonList(DefaultKeySizeConstraint.MAX__KEY_SIZE_EXCEEDED_VIOLATION), constraint.check(null, m)); m = new Mutation("rowid"); m.put(new Text(oversized), new Text("colq"), new Value(new byte[] {})); assertEquals( Collections.singletonList(DefaultKeySizeConstraint.MAX__KEY_SIZE_EXCEEDED_VIOLATION), constraint.check(null, m)); m = new Mutation(large); m.put(new Text(large), new Text(large), new Value(new byte[] {})); assertEquals( Collections.singletonList(DefaultKeySizeConstraint.MAX__KEY_SIZE_EXCEEDED_VIOLATION), constraint.check(null, m)); }