@Test public void testGetResources() throws Exception { expect(viewContext.getProperties()).andReturn(prepareViewContextProperties()).anyTimes(); expect(dataSource.getConnection("host1", "1234", "gpadmin-user", "gpadmin-password")).andReturn(connection); expect(connection.createStatement()).andReturn(statement); expect(statement.executeQuery(anyString())).andReturn(rs); expect(rs.getMetaData()).andReturn(rsMetaData); expect(rsMetaData.getColumnCount()).andReturn(2); expect(rs.next()).andReturn(true); expect(rsMetaData.getColumnName(1)).andReturn("procpid"); expect(rs.getObject(1)).andReturn(10); expect(rsMetaData.getColumnName(2)).andReturn("text"); expect(rs.getObject(2)).andReturn("text-10"); expect(rs.next()).andReturn(true); expect(rsMetaData.getColumnName(1)).andReturn("procpid"); expect(rs.getObject(1)).andReturn(20); expect(rsMetaData.getColumnName(2)).andReturn("text"); expect(rs.getObject(2)).andReturn("text-20"); expect(rs.next()).andReturn(false); rs.close(); expectLastCall().once(); statement.close(); expectLastCall().once(); connection.close(); expectLastCall().once(); replayAll(); Set<QueryResource> results = provider.getResources(null); assertEquals(2, results.size()); Set<String> ids = new HashSet<>(); ids.add("10"); ids.add("20"); for (QueryResource query : results) { String id = query.getId(); ids.remove(id); assertEquals(id, query.getAttributes().get("procpid").toString()); assertEquals("text-" + id, query.getAttributes().get("text")); } assertTrue(ids.isEmpty()); verifyAll(); }
@Override public Set<QueryResource> getResources(ReadRequest request) throws SystemException, NoSuchResourceException, UnsupportedPropertyException { Set<QueryResource> resources; try { LOG.debug("Get queries: View Context Properties = {}", viewContext.getProperties()); resources = getQueries(); LOG.debug("Retrieved {} queries from HAWQ Master", resources.size()); } catch (SQLException e) { LOG.error(e.getMessage(), e); throw new SystemException("Can't get current queries.", e); } return resources; }
QueryResourceProvider implements ResourceProvider<QueryResource> { @Override public Set<QueryResource> getResources(ReadRequest request) throws SystemException, NoSuchResourceException, UnsupportedPropertyException { Set<QueryResource> resources; try { LOG.debug("Get queries: View Context Properties = {}", viewContext.getProperties()); resources = getQueries(); LOG.debug("Retrieved {} queries from HAWQ Master", resources.size()); } catch (SQLException e) { LOG.error(e.getMessage(), e); throw new SystemException("Can't get current queries.", e); } return resources; } }
QueryResourceProvider implements ResourceProvider<QueryResource> { @Override public Set<QueryResource> getResources(ReadRequest request) throws SystemException, NoSuchResourceException, UnsupportedPropertyException { Set<QueryResource> resources; try { LOG.debug("Get queries: View Context Properties = {}", viewContext.getProperties()); resources = getQueries(); LOG.debug("Retrieved {} queries from HAWQ Master", resources.size()); } catch (SQLException e) { LOG.error(e.getMessage(), e); throw new SystemException("Can't get current queries.", e); } return resources; }  }
QueryResourceProvider implements ResourceProvider<QueryResource> { @Override public Set<QueryResource> getResources(ReadRequest request) throws SystemException, NoSuchResourceException, UnsupportedPropertyException { Set<QueryResource> resources; try { LOG.debug("Get queries: View Context Properties = {}", viewContext.getProperties()); resources = getQueries(); LOG.debug("Retrieved {} queries from HAWQ Master", resources.size()); } catch (SQLException e) { LOG.error(e.getMessage(), e); throw new SystemException("Can't get current queries.", e); } return resources; }  @Override QueryResource getResource(String resourceId, Set<String> propertyIds); @Override Set<QueryResource> getResources(ReadRequest request); @Override void createResource(String resourceId, Map<String, Object> stringObjectMap); @Override boolean updateResource(String resourceId, Map<String, Object> stringObjectMap); @Override boolean deleteResource(String resourceId); }
QueryResourceProvider implements ResourceProvider<QueryResource> { @Override public Set<QueryResource> getResources(ReadRequest request) throws SystemException, NoSuchResourceException, UnsupportedPropertyException { Set<QueryResource> resources; try { LOG.debug("Get queries: View Context Properties = {}", viewContext.getProperties()); resources = getQueries(); LOG.debug("Retrieved {} queries from HAWQ Master", resources.size()); } catch (SQLException e) { LOG.error(e.getMessage(), e); throw new SystemException("Can't get current queries.", e); } return resources; }  @Override QueryResource getResource(String resourceId, Set<String> propertyIds); @Override Set<QueryResource> getResources(ReadRequest request); @Override void createResource(String resourceId, Map<String, Object> stringObjectMap); @Override boolean updateResource(String resourceId, Map<String, Object> stringObjectMap); @Override boolean deleteResource(String resourceId);  }