test_class.file: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLErrPacketFactoryTest.java
test_class.identifier: PostgreSQLErrPacketFactoryTest
test_case.body: @Test
      public void assertPSQLExceptionWithServerErrorMessageNotNull() throws NoSuchFieldException, IllegalAccessException {
          ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
          when(serverErrorMessage.getSeverity()).thenReturn("severity");
          when(serverErrorMessage.getSQLState()).thenReturn("sqlState");
          when(serverErrorMessage.getMessage()).thenReturn("message");
          when(serverErrorMessage.getPosition()).thenReturn(1);
          PostgreSQLErrorResponsePacket actual = PostgreSQLErrPacketFactory.newInstance(new PSQLException(serverErrorMessage));
          Field packetField = PostgreSQLErrorResponsePacket.class.getDeclaredField("fields");
          packetField.setAccessible(true);
          Map<Character, String> fields = (Map<Character, String>) packetField.get(actual);
          assertThat(fields.get(PostgreSQLErrorResponsePacket.FIELD_TYPE_SEVERITY), is("severity"));
          assertThat(fields.get(PostgreSQLErrorResponsePacket.FIELD_TYPE_CODE), is("sqlState"));
          assertThat(fields.get(PostgreSQLErrorResponsePacket.FIELD_TYPE_MESSAGE), is("message"));
          assertThat(fields.get(PostgreSQLErrorResponsePacket.FIELD_TYPE_POSITION), is("1"));
      }
test_case.class_method_signature: PostgreSQLErrPacketFactoryTest.assertPSQLExceptionWithServerErrorMessageNotNull()
test_case.full_signature: @Test public void assertPSQLExceptionWithServerErrorMessageNotNull()
test_case.identifier: assertPSQLExceptionWithServerErrorMessageNotNull
test_case.invocations: mock thenReturn when getSeverity thenReturn when getSQLState thenReturn when getMessage thenReturn when getPosition newInstance getDeclaredField setAccessible get assertThat get is assertThat get is assertThat get is assertThat get is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void assertPSQLExceptionWithServerErrorMessageNotNull()
focal_class.file: shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/PostgreSQLErrPacketFactory.java
focal_class.identifier: PostgreSQLErrPacketFactory
focal_class.class_method_signature: PostgreSQLErrPacketFactory.newInstance(final Exception cause)
focal_class.full_signature: public static PostgreSQLErrorResponsePacket newInstance(final Exception cause)
focal_class.identifier: newInstance
focal_class.modifiers: public static
focal_class.parameters: (final Exception cause)
focal_class.return: PostgreSQLErrorResponsePacket
focal_class.signature: PostgreSQLErrorResponsePacket newInstance(final Exception cause)
focal_method.body: public static PostgreSQLErrorResponsePacket newInstance(final Exception cause) {
          if (cause instanceof PSQLException) {
              PostgreSQLErrorResponsePacket result = new PostgreSQLErrorResponsePacket();
              ServerErrorMessage serverErrorMessage = ((PSQLException) cause).getServerErrorMessage();
              if (null == serverErrorMessage) {
                  PSQLException ex = (PSQLException) cause;
                  result.addField(PostgreSQLErrorResponsePacket.FIELD_TYPE_CODE, ex.getSQLState());
                  result.addField(PostgreSQLErrorResponsePacket.FIELD_TYPE_MESSAGE, ex.getMessage());
              } else {
                  result.addField(PostgreSQLErrorResponsePacket.FIELD_TYPE_SEVERITY, serverErrorMessage.getSeverity());
                  result.addField(PostgreSQLErrorResponsePacket.FIELD_TYPE_CODE, serverErrorMessage.getSQLState());
                  result.addField(PostgreSQLErrorResponsePacket.FIELD_TYPE_MESSAGE, serverErrorMessage.getMessage());
                  result.addField(PostgreSQLErrorResponsePacket.FIELD_TYPE_POSITION, Integer.toString(serverErrorMessage.getPosition()));
              }
              return result;
          }
          PostgreSQLErrorResponsePacket result = new PostgreSQLErrorResponsePacket();
          result.addField(PostgreSQLErrorResponsePacket.FIELD_TYPE_MESSAGE, cause.getMessage());
          return result;
      }
focal_method.class_method_signature: PostgreSQLErrPacketFactory.newInstance(final Exception cause)
focal_method.full_signature: public static PostgreSQLErrorResponsePacket newInstance(final Exception cause)
focal_method.identifier: newInstance
focal_method.invocations: getServerErrorMessage addField getSQLState addField getMessage addField getSeverity addField getSQLState addField getMessage addField toString getPosition addField getMessage
focal_method.modifiers: public static
focal_method.parameters: (final Exception cause)
focal_method.return: PostgreSQLErrorResponsePacket
focal_method.signature: PostgreSQLErrorResponsePacket newInstance(final Exception cause)