test_class.declarator: exception = ExpectedException.none()
test_class.modifier: @Rule
    public final
test_class.original_string: @Rule
    public final ExpectedException exception = ExpectedException.none();
test_class.type: ExpectedException
test_class.var_name: exception
test_class.file: session-replacement/src/test/java/com/amadeus/session/TestEncryptingSerializerDeserializer.java
test_class.identifier: TestEncryptingSerializerDeserializer
test_case.body: @Test
    public void testDeserialize() {
      EncryptingSerializerDeserializer serializer = new EncryptingSerializerDeserializer();
      SessionManager sessionManager = mock(SessionManager.class);
      SessionConfiguration configuration = new SessionConfiguration();
      configuration.setUsingEncryption(true);
      configuration.setEncryptionKey("test");
      when(sessionManager.getMetrics()).thenReturn(new MetricRegistry());
      when(sessionManager.getConfiguration()).thenReturn(configuration);
      serializer.setSessionManager(sessionManager);
      EncryptingSerializerDeserializer tempSerializer = new EncryptingSerializerDeserializer();
      SessionManager sm = mock(SessionManager.class);
      when(sm.getMetrics()).thenReturn(new MetricRegistry());
      when(sm.getConfiguration()).thenReturn(configuration);
      tempSerializer.setSessionManager(sm);
      Date now = new Date();
      byte[] serializedString = serializer.serialize("String");
      byte[] serializedDate = serializer.serialize(now);
      byte[] serializedNull = serializer.serialize(null);
  
      assertEquals(null, serializer.deserialize(serializedNull));
      assertEquals("String", serializer.deserialize(serializedString));
      assertEquals(now, serializer.deserialize(serializedDate));
    }
test_case.class_method_signature: TestEncryptingSerializerDeserializer.testDeserialize()
test_case.full_signature: @Test public void testDeserialize()
test_case.identifier: testDeserialize
test_case.invocations: mock setUsingEncryption setEncryptionKey thenReturn when getMetrics thenReturn when getConfiguration setSessionManager mock thenReturn when getMetrics thenReturn when getConfiguration setSessionManager serialize serialize serialize assertEquals deserialize assertEquals deserialize assertEquals deserialize
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDeserialize()
focal_class.declarator: wrapped
focal_class.modifier: private final
focal_class.original_string: private final SerializerDeserializer wrapped;
focal_class.type: SerializerDeserializer
focal_class.var_name: wrapped
focal_class.declarator: secretKey
focal_class.modifier: private
focal_class.original_string: private SecretKeySpec secretKey;
focal_class.type: SecretKeySpec
focal_class.var_name: secretKey
focal_class.declarator: random
focal_class.modifier: private
focal_class.original_string: private SecureRandom random;
focal_class.type: SecureRandom
focal_class.var_name: random
focal_class.file: session-replacement/src/main/java/com/amadeus/session/EncryptingSerializerDeserializer.java
focal_class.identifier: EncryptingSerializerDeserializer
focal_class.interfaces: implements SerializerDeserializer
focal_class.class_method_signature: EncryptingSerializerDeserializer.EncryptingSerializerDeserializer()
focal_class.full_signature: public  EncryptingSerializerDeserializer()
focal_class.identifier: EncryptingSerializerDeserializer
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  EncryptingSerializerDeserializer()
focal_class.class_method_signature: EncryptingSerializerDeserializer.EncryptingSerializerDeserializer(SerializerDeserializer wrapped)
focal_class.full_signature: public  EncryptingSerializerDeserializer(SerializerDeserializer wrapped)
focal_class.identifier: EncryptingSerializerDeserializer
focal_class.modifiers: public
focal_class.parameters: (SerializerDeserializer wrapped)
focal_class.signature:  EncryptingSerializerDeserializer(SerializerDeserializer wrapped)
focal_class.class_method_signature: EncryptingSerializerDeserializer.initKey(String key)
focal_class.full_signature:  void initKey(String key)
focal_class.identifier: initKey
focal_class.parameters: (String key)
focal_class.return: void
focal_class.signature: void initKey(String key)
focal_class.class_method_signature: EncryptingSerializerDeserializer.serialize(Object value)
focal_class.full_signature: @Override public byte[] serialize(Object value)
focal_class.identifier: serialize
focal_class.modifiers: @Override public
focal_class.parameters: (Object value)
focal_class.return: byte[]
focal_class.signature: byte[] serialize(Object value)
focal_class.class_method_signature: EncryptingSerializerDeserializer.deserialize(byte[] data)
focal_class.full_signature: @Override public Object deserialize(byte[] data)
focal_class.identifier: deserialize
focal_class.modifiers: @Override public
focal_class.parameters: (byte[] data)
focal_class.return: Object
focal_class.signature: Object deserialize(byte[] data)
focal_class.class_method_signature: EncryptingSerializerDeserializer.setSessionManager(SessionManager sessionManager)
focal_class.full_signature: @Override public void setSessionManager(SessionManager sessionManager)
focal_class.identifier: setSessionManager
focal_class.modifiers: @Override public
focal_class.parameters: (SessionManager sessionManager)
focal_class.return: void
focal_class.signature: void setSessionManager(SessionManager sessionManager)
focal_method.body: @Override
    public Object deserialize(byte[] data) {
      byte[] decrypted;
      try {
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        byte[] iv = new byte[16];
        System.arraycopy(data, 0, iv, 0, iv.length);
        cipher.init(Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(iv));
        decrypted = cipher.doFinal(data, iv.length, data.length-iv.length);
      } catch (Exception e) { // NOSONAR
        throw new IllegalStateException(e);
      }
      return wrapped.deserialize(decrypted);
    }
focal_method.class_method_signature: EncryptingSerializerDeserializer.deserialize(byte[] data)
focal_method.full_signature: @Override public Object deserialize(byte[] data)
focal_method.identifier: deserialize
focal_method.invocations: getInstance arraycopy init doFinal deserialize
focal_method.modifiers: @Override public
focal_method.parameters: (byte[] data)
focal_method.return: Object
focal_method.signature: Object deserialize(byte[] data)