### Question:
NfcUtils { public static GenerateSignatureResponseApdu generateSignature(NfcTranceiver card, int keyIndex, byte[] dataToSign, byte[] pin) throws IOException, NfcCardException { selectApplication(card); if (pin != null && pin.length > 0) { if (!verifyPin(card, pin)) { return new GenerateSignatureResponseApdu(new byte[]{}); } } GenerateSignatureApdu apdu = new GenerateSignatureApdu(keyIndex, dataToSign); return (GenerateSignatureResponseApdu) tranceive(card, apdu, "GENERATE SIGNATURE"); }  static GenerateSignatureResponseApdu generateSignature(NfcTranceiver card, int keyIndex,
                                                                  byte[] dataToSign, byte[] pin); static GetKeyInfoResponseApdu readPublicKeyOrCreateIfNotExists(NfcTranceiver card, int keyIndex); static boolean generateKeyFromSeed(NfcTranceiver card, byte[] seed, byte[] pin); static byte[] initializePinAndReturnPuk(NfcTranceiver card, byte[] pinBytes); static byte[] changePin(NfcTranceiver card, byte[] currentPin, byte[] newPin); static boolean unlockPin(NfcTranceiver card, byte[] puk); static boolean verifyPin(NfcTranceiver card, byte[] pin); static final byte[] AID_INFINEON_BLOCKCHAIN2GO; }### Answer:
@Test public void testGenerateSignature() throws IOException, NfcCardException { when(nfcTranceiver.transceive(any())).thenReturn(new byte[]{0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, (byte) 0x90, 0x00}); byte[] bytes = new byte[]{}; final GenerateSignatureResponseApdu responseApdu = NfcUtils.generateSignature(nfcTranceiver, 0, bytes, null); assertEquals(1, responseApdu.getSigCounterAsInteger()); assertEquals(2, responseApdu.getGlobalSigCounterAsInteger()); }
@Test public void testGenerateSignatureError() throws IOException, NfcCardException { when(nfcTranceiver.transceive(new byte[]{0x00, 0x18, 0x00, 0x00})).thenReturn(new byte[]{0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, (byte) 0x40, 0x00}); when(nfcTranceiver.transceive(any())).thenReturn(new byte[]{0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, (byte) 0x90, 0x00}); byte[] bytes = new byte[]{}; final GenerateSignatureResponseApdu responseApdu = NfcUtils.generateSignature(nfcTranceiver, 0, bytes, null); assertEquals(1, responseApdu.getSigCounterAsInteger()); assertEquals(2, responseApdu.getGlobalSigCounterAsInteger()); }