/** * Create a flow configuration that the service will forward to execution instances for execution * @param flowConfig flow configuration * @return {@link CreateResponse} */ @Override public CreateResponse create(FlowConfig flowConfig) { List<ServiceRequester> requestorList = this.requesterService.findRequesters(this); try { String serialized = this.requesterService.serialize(requestorList); flowConfig.getProperties().put(RequesterService.REQUESTER_LIST, serialized); LOG.info("Rest requester list is " + serialized); } catch (IOException e) { throw new FlowConfigLoggedException(HttpStatus.S_401_UNAUTHORIZED, "cannot get who is the requester", e); } return this.flowConfigsResourceHandler.createFlowConfig(flowConfig); }
public void testSerDerWithEmptyRequester() throws IOException { List<ServiceRequester> list = new ArrayList<>(); RequesterService rs = new NoopRequesterService(ConfigBuilder.create().build()); String serialize = rs.serialize(list); Properties props = new Properties(); props.put(RequesterService.REQUESTER_LIST, serialize); Config initConfig = ConfigBuilder.create().build(); Config config = initConfig.withFallback(ConfigFactory.parseString(props.toString()).resolve()); Properties props2 = ConfigUtils.configToProperties(config); String serialize2 = props2.getProperty(RequesterService.REQUESTER_LIST); Assert.assertTrue(serialize.equals(serialize2)); List<ServiceRequester> list2 = rs.deserialize(serialize); Assert.assertTrue(list.equals(list2)); }
public void testSerDerWithConfig() throws IOException { ServiceRequester sr1 = new ServiceRequester("kafkaetl", "user", "dv"); ServiceRequester sr2 = new ServiceRequester("gobblin", "group", "dv"); ServiceRequester sr3 = new ServiceRequester("crm-backend", "service", "cert"); List<ServiceRequester> list = new ArrayList<>(); sr1.getProperties().put("customKey", "${123}"); list.add(sr1); list.add(sr2); list.add(sr3); RequesterService rs = new NoopRequesterService(ConfigBuilder.create().build()); String serialize = rs.serialize(list); Properties props = new Properties(); props.put(RequesterService.REQUESTER_LIST, serialize); Config initConfig = ConfigBuilder.create().build(); Config config = initConfig.withFallback(ConfigFactory.parseString(props.toString()).resolve()); Properties props2 = ConfigUtils.configToProperties(config); String serialize2 = props2.getProperty(RequesterService.REQUESTER_LIST); Assert.assertTrue(serialize.equals(serialize2)); List<ServiceRequester> list2 = rs.deserialize(serialize); Assert.assertTrue(list.equals(list2)); } }