public List<Entity> query(String gqlQuery) {
    try {
      QueryResults<Entity> queryResults =
          datastore.run(
              GqlQuery.newGqlQueryBuilder(ResultType.ENTITY, gqlQuery)
                  .setNamespace(namespace)
                  .build());

      List<Entity> entities = new ArrayList<>();

      while (queryResults.hasNext()) {
        Entity entity = queryResults.next();
        entities.add(entity);

        // Mark for deletion if namespace matches the test
        if (entity.getKey().getNamespace().equals(namespace)) {
          keys.add(entity.getKey());
        }
      }
      return entities;
    } catch (Exception e) {
      throw new DatastoreResourceManagerException("Error running Datastore query", e);
    }
  }
@Test
  public void testQuery() {
    // Prepare test data
    String gqlQuery = "SELECT * FROM test_kind";

    // Mock the Datastore run method
    QueryResults<Entity> mockResult = mock(QueryResults.class);
    Entity mockEntity = mock(Entity.class);
    when(datastoreMock.run(any(GqlQuery.class))).thenReturn(mockResult);
    when(mockResult.hasNext()).thenReturn(true).thenReturn(false);
    when(mockResult.next()).thenReturn(mockEntity);

    Key mockKey = mock(Key.class);
    when(mockEntity.getKey()).thenReturn(mockKey);
    when(mockKey.getNamespace()).thenReturn("test-namespace");

    // Execute the method under test
    List<Entity> result = resourceManager.query(gqlQuery);
    resourceManager.cleanupAll();

    // Verify the result
    assertThat(result).isNotEmpty();
    assertThat(result.get(0)).isEqualTo(mockEntity);

    verify(datastoreMock).delete(mockKey);
  }