### Question:
AsnOctetStringBasedObjectCodec extends AsnPrimitiveCodec<T> { public final void setBytes(byte[] bytes) { Objects.requireNonNull(bytes); validateSize(bytes); this.bytes = bytes; this.onValueChangedEvent(); } AsnOctetStringBasedObjectCodec(AsnSizeConstraint sizeConstraintInOctets);  AsnOctetStringBasedObjectCodec(int fixedSizeConstraint);  AsnOctetStringBasedObjectCodec(int minSize, int maxSize); final byte[] getBytes(); final void setBytes(byte[] bytes); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }### Answer:
@Test(expected = CodecException.class) public void setBytesTooBig() { final AsnOctetStringBasedObjectCodec codec = createCodec(new AsnSizeConstraint(0, 1)); final byte[] bytes = new byte[2]; try { codec.setBytes(bytes); } catch (CodecException e) { assertThat(e.getMessage()).isEqualTo("Invalid octet string length. Expected < 1, got 2"); throw e; } }
@Test(expected = CodecException.class) public void setBytesTooBigForFixedSize() { final AsnOctetStringBasedObjectCodec codec = createCodec(new AsnSizeConstraint(1, 1)); final byte[] bytes = new byte[2]; try { codec.setBytes(bytes); } catch (CodecException e) { assertThat(e.getMessage()).isEqualTo("Invalid octet string length. Expected < 1, got 2"); throw e; } }
@Test(expected = CodecException.class) public void setBytesTooSmall() { final AsnOctetStringBasedObjectCodec codec = createCodec(new AsnSizeConstraint(1, 2)); final byte[] bytes = new byte[0]; try { codec.setBytes(bytes); } catch (CodecException e) { assertThat(e.getMessage()).isEqualTo("Invalid octet string length. Expected > 1, got 0"); throw e; } }
@Test(expected = CodecException.class) public void setBytesTooSmallForFixedSize() { final AsnOctetStringBasedObjectCodec codec = createCodec(new AsnSizeConstraint(1, 1)); final byte[] bytes = new byte[0]; try { codec.setBytes(bytes); } catch (CodecException e) { assertThat(e.getMessage()).isEqualTo("Invalid octet string length. Expected > 1, got 0"); throw e; } }