@Test public void shouldSendRequestsToMeta() { final MetadataConfigurationProperties config = new MetadataConfigurationProperties(); config.setService("syndesis-meta"); final Client client = mock(Client.class); final ConnectorPropertiesHandler handler = new ConnectorPropertiesHandler(config) { @Override protected HystrixExecutable<DynamicConnectionPropertiesMetadata> createMetadataConnectionPropertiesCommand(final String connectorId) { return new MetadataConnectionPropertiesCommand(config, connectorId, Collections.emptyMap()){ @Override protected Client createClient() { return client; } }; } }; final ArgumentCaptor<String> url = ArgumentCaptor.forClass(String.class); final WebTarget target = mock(WebTarget.class); when(client.target(url.capture())).thenReturn(target); final Invocation.Builder builder = mock(Invocation.Builder.class); when(target.request(MediaType.APPLICATION_JSON)).thenReturn(builder); final Map<String, Object> properties = Collections.emptyMap(); final Map<String, List<WithDynamicProperties.ActionPropertySuggestion>> dynamicProperties = buildProperties(); final DynamicConnectionPropertiesMetadata dynamicConnectionPropertiesMetadata = new DynamicConnectionPropertiesMetadata.Builder() .properties(dynamicProperties) .build(); when(builder.post(Entity.entity(properties, MediaType.APPLICATION_JSON_TYPE),DynamicConnectionPropertiesMetadata.class)) .thenReturn(dynamicConnectionPropertiesMetadata); final DynamicConnectionPropertiesMetadata received = handler.dynamicConnectionProperties("connectorId"); assertThat(received).isSameAs(dynamicConnectionPropertiesMetadata); assertThat(url.getValue()).isEqualTo("http: }
@POST @Produces(MediaType.APPLICATION_JSON) public DynamicConnectionPropertiesMetadata dynamicConnectionProperties(@PathParam("id") final String connectorId) { final HystrixExecutable<DynamicConnectionPropertiesMetadata> meta = createMetadataConnectionPropertiesCommand(connectorId); return meta.execute(); }
ConnectorPropertiesHandler { @POST @Produces(MediaType.APPLICATION_JSON) public DynamicConnectionPropertiesMetadata dynamicConnectionProperties(@PathParam("id") final String connectorId) { final HystrixExecutable<DynamicConnectionPropertiesMetadata> meta = createMetadataConnectionPropertiesCommand(connectorId); return meta.execute(); } }
ConnectorPropertiesHandler { @POST @Produces(MediaType.APPLICATION_JSON) public DynamicConnectionPropertiesMetadata dynamicConnectionProperties(@PathParam("id") final String connectorId) { final HystrixExecutable<DynamicConnectionPropertiesMetadata> meta = createMetadataConnectionPropertiesCommand(connectorId); return meta.execute(); } ConnectorPropertiesHandler(final MetadataConfigurationProperties config); }
ConnectorPropertiesHandler { @POST @Produces(MediaType.APPLICATION_JSON) public DynamicConnectionPropertiesMetadata dynamicConnectionProperties(@PathParam("id") final String connectorId) { final HystrixExecutable<DynamicConnectionPropertiesMetadata> meta = createMetadataConnectionPropertiesCommand(connectorId); return meta.execute(); } ConnectorPropertiesHandler(final MetadataConfigurationProperties config); @POST @Produces(MediaType.APPLICATION_JSON) DynamicConnectionPropertiesMetadata dynamicConnectionProperties(@PathParam("id") final String connectorId); }
ConnectorPropertiesHandler { @POST @Produces(MediaType.APPLICATION_JSON) public DynamicConnectionPropertiesMetadata dynamicConnectionProperties(@PathParam("id") final String connectorId) { final HystrixExecutable<DynamicConnectionPropertiesMetadata> meta = createMetadataConnectionPropertiesCommand(connectorId); return meta.execute(); } ConnectorPropertiesHandler(final MetadataConfigurationProperties config); @POST @Produces(MediaType.APPLICATION_JSON) DynamicConnectionPropertiesMetadata dynamicConnectionProperties(@PathParam("id") final String connectorId);  }