### Question:
TPM2ProvisionerState { public static TPM2ProvisionerState getTPM2ProvisionerState( final CrudManager<TPM2ProvisionerState> crudManager, final byte[] nonce) { try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(nonce))) { long firstPartOfNonce = dis.readLong(); TPM2ProvisionerState stateFound = crudManager.get(firstPartOfNonce); if (Arrays.areEqual(stateFound.getNonce(), nonce)) { return stateFound; } } catch (IOException | NullPointerException e) { return null; } return null; } protected  TPM2ProvisionerState();  TPM2ProvisionerState(final byte[] nonce, final byte[] identityClaim); byte[] getNonce(); byte[] getIdentityClaim(); static TPM2ProvisionerState getTPM2ProvisionerState(
            final CrudManager<TPM2ProvisionerState> crudManager,
            final byte[] nonce);  }### Answer:
@Test @SuppressWarnings("unchecked") public final void testGetTPM2ProvisionerStateNullNonce() throws IOException { CrudManager<TPM2ProvisionerState> crudManager = mock(CrudManager.class); Random rand = new Random(); byte[] nonce = new byte[32]; byte[] identityClaim = new byte[360]; rand.nextBytes(nonce); rand.nextBytes(identityClaim); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(nonce)); Long index = dis.readLong(); dis.close(); TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); when(crudManager.get(index)).thenReturn(value); TPM2ProvisionerState tpm2ProvisionerState = TPM2ProvisionerState.getTPM2ProvisionerState(crudManager, null); Assert.assertNull(tpm2ProvisionerState); }
@Test @SuppressWarnings("unchecked") public final void testGetTPM2ProvisionerStateNonceTooSmall() throws IOException { CrudManager<TPM2ProvisionerState> crudManager = mock(CrudManager.class); Random rand = new Random(); byte[] nonce = new byte[32]; byte[] identityClaim = new byte[360]; rand.nextBytes(nonce); rand.nextBytes(identityClaim); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(nonce)); Long index = dis.readLong(); dis.close(); TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); when(crudManager.get(index)).thenReturn(value); TPM2ProvisionerState tpm2ProvisionerState = TPM2ProvisionerState.getTPM2ProvisionerState(crudManager, new byte[7]); Assert.assertNull(tpm2ProvisionerState); }