@Test
public void testNewKey() throws Exception {

  failExpected(null, "Null message");
  OtpKeyRequest r = new OtpKeyRequest();
  failExpected(r, "mt message");
  r.setOtpSystemId(CLEAR_CHANNEL_ID);
  r.setKeyFunction(KeyFunction.NEW);
  r.setKeySize(-32);
  failExpected(r, "negative size");
  r.setKeySize(KEY_SIZE);
  r.setKeyFunction(null);
  failExpected(r, "No key function");
  r.setKeyFunction(KeyFunction.NEW);
  r.setKeySize(maxKeySize + 1);
  failExpected(r, "> max key size");
  r.setKeySize(KEY_SIZE);
  Response rep = processor.process(r);
  assertEquals(ResponseCode.SUCCESS, rep.getResponseCode());
  assertNotNull(rep.getPayload());
  assertEquals(1, rep.getPayload().length);
  assertTrue(rep.getPayload()[0] instanceof byte[]);
  byte[] b = (byte[]) rep.getPayload()[0];
  assertEquals(KEY_SIZE.intValue(), b.length);
}