private void checkExpr(int numParts, ExprNodeGenericFuncDesc expr) throws Exception {
    List<Partition> partitions = new ArrayList<>();
    byte[] exprBytes = SerializationUtilities.serializeObjectWithTypeInformation(expr);
    getClient().listPartitionsByExpr(DB_NAME, TABLE_NAME, exprBytes,
        null, (short) -1, partitions);
    assertEquals("Partition check failed: " + expr.getExprString(), numParts, partitions.size());
    assertPartitionsHaveCorrectParams(partitions);

    PartitionsByExprRequest req = new PartitionsByExprRequest(DB_NAME, TABLE_NAME,
        ByteBuffer.wrap(exprBytes));
    List<org.apache.hadoop.hive.metastore.api.PartitionSpec> msParts =
        new ArrayList<>();
    getClient().listPartitionsSpecByExpr(req, msParts);

    int numPartitions = 0;
    for (org.apache.hadoop.hive.metastore.api.PartitionSpec partitionSpec : msParts) {
      assertTrue(partitionSpec.getPartitionList() == null ||
          partitionSpec.getPartitionList().getPartitions() == null ||
          partitionSpec.getPartitionList().getPartitions().isEmpty());
      for (PartitionWithoutSD partitionWithoutSD: partitionSpec.getSharedSDPartitionSpec().getPartitions()) {
        numPartitions ++;
        Map<String, String> parameters = partitionWithoutSD.getParameters();
        assertTrue("included parameter key is not found in the partition",
            parameters.keySet().containsAll(includeKeys));
        assertFalse("excluded parameter key is found in the partition",
            parameters.keySet().stream().anyMatch(key -> excludeKeys.contains(key)));
        assertEquals(includeKeys.size(), parameters.size());
      }
    }
    assertEquals("Partition check failed: " + expr.getExprString(), numParts, numPartitions);
  }
Test class for list partitions with configurable include/exclude pattern on parameters.
Embedded Metastore uses JDO, Remote Metastore uses direct SQL to query the partitions:
MetaStoreFactoryForTests.getMetaStores()
ql/src/test/org/apache/hadoop/hive/metastore/TestListPartitionsWithXIncludeParams.java