### Question:
SPPDecoder implements MALDecoder { @Override public Element decodeElement(final Element element) throws IllegalArgumentException, MALException { if (element == null) { throw new IllegalArgumentException(ILLEGAL_NULL_ARGUMENT); } return element.decode(this); } SPPDecoder(final InputStream inputStream, final Map properties); @Override Boolean decodeBoolean(); @Override Boolean decodeNullableBoolean(); @Override Float decodeFloat(); @Override Float decodeNullableFloat(); @Override Double decodeDouble(); @Override Double decodeNullableDouble(); @Override Byte decodeOctet(); @Override Byte decodeNullableOctet(); @Override UOctet decodeUOctet(); @Override UOctet decodeNullableUOctet(); @Override Short decodeShort(); @Override Short decodeNullableShort(); @Override UShort decodeUShort(); @Override UShort decodeNullableUShort(); @Override Integer decodeInteger(); @Override Integer decodeNullableInteger(); @Override UInteger decodeUInteger(); @Override UInteger decodeNullableUInteger(); @Override Long decodeLong(); @Override Long decodeNullableLong(); @Override ULong decodeULong(); @Override ULong decodeNullableULong(); @Override String decodeString(); @Override String decodeNullableString(); @Override Blob decodeBlob(); @Override Blob decodeNullableBlob(); @Override Duration decodeDuration(); @Override Duration decodeNullableDuration(); @Override FineTime decodeFineTime(); @Override FineTime decodeNullableFineTime(); @Override Identifier decodeIdentifier(); @Override Identifier decodeNullableIdentifier(); @Override Time decodeTime(); @Override Time decodeNullableTime(); @Override URI decodeURI(); @Override URI decodeNullableURI(); @Override Element decodeElement(final Element element); @Override Element decodeNullableElement(final Element element); @Override Attribute decodeAttribute(); @Override Attribute decodeNullableAttribute(); @Override MALListDecoder createListDecoder(final List list);  }### Answer:
@Test public void testDecodeElement1() throws Exception { newBuffer(new byte[]{0}); Element e = new URI(); Element ret = decoder.decodeElement(e); assertEquals(new URI(""), ret); assertNotSame(e, ret); }
@Test public void testDecodeElement2() throws Exception { newBuffer(new byte[]{(byte) 0b10000000, (byte) 0b00000001}); Element e = new UShort(); Element ret = decoder.decodeElement(e); assertEquals(new UShort(128), ret); assertNotSame(e, ret); }
@Test public void testDecodeElement3() throws Exception { newBuffer(new byte[]{(byte) 0b10000000}); Element e = new Union(new Byte((byte) 0)); Element ret = decoder.decodeElement(e); assertEquals(new Union(new Byte((byte) -128)), ret); assertNotSame(e, ret); }
@Test public void testDecodeElementExpectedException1() throws Exception { newBuffer(new byte[]{}); try { decoder.decodeElement(new URI()); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }
@Test public void testDecodeElementExpectedException2() throws Exception { newBuffer(new byte[]{}); try { decoder.decodeElement(null); fail("Expected exception, but none thrown."); } catch (IllegalArgumentException ex) { assertEquals(SPPEncoder.ILLEGAL_NULL_ARGUMENT, ex.getMessage()); } }
@Test public void testDecodeElementExpectedException3() throws Exception { newBuffer(new byte[]{1}); try { decoder.decodeElement(new URI()); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INSUFFICIENT_DATA, ex.getMessage()); } }
@Test public void testDecodeElementExpectedException4() throws Exception { newBuffer(new byte[]{(byte) 0b10000000, (byte) 0b10000000, (byte) 0b10000000}); try { decoder.decodeElement(new Union(Short.valueOf((short) 0))); fail("Expected exception, but none thrown."); } catch (MALException ex) { assertEquals(SPPDecoder.INVALID_VALUE, ex.getMessage()); } }