Search in sources :

Example 41 with QueryParam

use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.

the class NotificationServiceImplTest method testFindNotifications.

@Test
public void testFindNotifications() throws Exception {
    new Expectations() {

        {
            mockCtx.getConfig();
            times = 3;
            result = mockNotifierConfig;
            mockNotifierConfig.getClassName();
            times = 1;
            result = "Test";
            mockNotifierConfig.getJarPath();
            times = 1;
            result = "/tmp/test.jar";
            mockProxyUtil.loadClassFromJar("/tmp/test.jar", "Test");
            result = mockNotifier;
        }
    };
    notificationService.register("test_notifier", mockCtx);
    QueryParam qp1 = new QueryParam("one", "1");
    QueryParam qp2 = new QueryParam("two", "2");
    QueryParam qp3 = new QueryParam("numRows", "5");
    notificationService.findNotifications(Arrays.asList(qp1, qp2, qp3));
    new Verifications() {

        {
            Criteria<Notification> criteria;
            mockNotificationStore.findEntities(criteria = withCapture());
            // System.out.println("criteria = " + criteria);
            assertEquals(criteria.clazz(), Notification.class);
            assertEquals(criteria.numRows(), 5);
            assertEquals(criteria.fieldRestrictions().size(), 2);
            assertEquals(criteria.fieldRestrictions().get(0).getValue(), "1");
            assertEquals(criteria.fieldRestrictions().get(1).getValue(), "2");
        }
    };
    notificationService.findNotifications(Arrays.asList(qp1, qp2));
    new Verifications() {

        {
            Criteria<Notification> criteria;
            mockNotificationStore.findEntities(criteria = withCapture());
            // System.out.println("criteria = " + criteria);
            assertEquals(criteria.clazz(), Notification.class);
            assertEquals(0, criteria.numRows());
            assertEquals(criteria.fieldRestrictions().size(), 2);
            assertEquals(criteria.fieldRestrictions().get(0).getValue(), "1");
            assertEquals(criteria.fieldRestrictions().get(1).getValue(), "2");
        }
    };
}
Also used : Expectations(mockit.Expectations) QueryParam(com.hortonworks.registries.common.QueryParam) Verifications(mockit.Verifications) Notification(com.hortonworks.streamline.streams.notification.Notification) Test(org.junit.Test)

Example 42 with QueryParam

use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.

the class StreamCatalogService method listTopologyTestRunHistory.

public Collection<TopologyTestRunHistory> listTopologyTestRunHistory(Long topologyId, Long versionId) {
    List<QueryParam> queryParams = new ArrayList<>();
    queryParams.add(new QueryParam("topologyId", String.valueOf(topologyId)));
    queryParams.add(new QueryParam("versionId", String.valueOf(versionId)));
    return dao.find(TopologyTestRunHistory.NAMESPACE, queryParams);
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) ArrayList(java.util.ArrayList)

Example 43 with QueryParam

use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.

the class StreamCatalogService method removeAllTopologyTestSinks.

private void removeAllTopologyTestSinks(TopologySink topologySink) {
    QueryParam sinkIdQuery = new QueryParam("sinkId", String.valueOf(topologySink.getId()));
    Collection<TopologyTestRunCaseSink> sinks = listTopologyTestRunCaseSink(Collections.singletonList(sinkIdQuery));
    if (sinks != null) {
        sinks.forEach(s -> removeTopologyTestRunCaseSink(s.getId()));
    }
}
Also used : TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)

Example 44 with QueryParam

use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.

the class TopologyDagBuilder method queryParam.

private List<QueryParam> queryParam(Topology topology) {
    List<QueryParam> queryParams = new ArrayList<>();
    queryParams.add(new QueryParam(TopologyComponent.TOPOLOGYID, topology.getId().toString()));
    queryParams.add(new QueryParam(TopologyComponent.VERSIONID, topology.getVersionId().toString()));
    return queryParams;
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) ArrayList(java.util.ArrayList)

Example 45 with QueryParam

use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.

the class SecurityCatalogService method fillRoles.

private User fillRoles(User user) {
    User res = null;
    if (user != null) {
        User userWithRole = new User(user);
        userWithRole.setRoles(Collections.emptySet());
        List<QueryParam> qps = QueryParam.params(UserRole.USER_ID, String.valueOf(user.getId()));
        listUserRoles(qps).forEach(userRole -> {
            userWithRole.addRole(getRole(userRole.getRoleId()).getName());
        });
        res = userWithRole;
    }
    return res;
}
Also used : User(com.hortonworks.streamline.streams.security.catalog.User) QueryParam(com.hortonworks.registries.common.QueryParam)

Aggregations

QueryParam (com.hortonworks.registries.common.QueryParam)72 ArrayList (java.util.ArrayList)42 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)22 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)22 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)22 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)22 IOException (java.io.IOException)8 SchemaNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaNotFoundException)7 StorableKey (com.hortonworks.registries.storage.StorableKey)7 OrderByField (com.hortonworks.registries.storage.OrderByField)6 HashSet (java.util.HashSet)6 SchemaVersionLifecycleContext (com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleContext)5 TopologyComponentBundle (com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)5 Timed (com.codahale.metrics.annotation.Timed)4 Preconditions (com.google.common.base.Preconditions)4 SchemaBranchNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaBranchNotFoundException)4 StorageException (com.hortonworks.registries.storage.exception.StorageException)4 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)4 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4