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");
}
};
}
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);
}
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()));
}
}
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;
}
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;
}
Aggregations