NgsiClient { public HttpHeaders getRequestHeaders() { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setContentType(MediaType.APPLICATION_XML); requestHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_XML)); return requestHeaders; }  void shutdownGracefully(); ListenableFuture<UpdateContextResponse> updateContext(String url, HttpHeaders httpHeaders, UpdateContext updateContext); ListenableFuture<SubscribeContextResponse> subscribeContext(String url, HttpHeaders httpHeaders, SubscribeContext subscribeContext); ListenableFuture<UpdateContextSubscriptionResponse> updateContextSubscription(String url, HttpHeaders httpHeaders, UpdateContextSubscription updateContextSubscription); ListenableFuture<UnsubscribeContextResponse> unsubscribeContext(String url, HttpHeaders httpHeaders, String subscriptionId); ListenableFuture<NotifyContextResponse> notifyContext(String url, HttpHeaders httpHeaders, NotifyContext notifyContext); ListenableFuture<NotifyContextResponse> notifyContextCustomURL(String customURL, HttpHeaders httpHeaders, NotifyContext notifyContext); ListenableFuture<QueryContextResponse> queryContext(String url, HttpHeaders httpHeaders, QueryContext queryContext); ListenableFuture<RegisterContextResponse> registerContext(String url, HttpHeaders httpHeaders, RegisterContext registerContext); HttpHeaders getRequestHeaders(); HttpHeaders getRequestHeaders(String url); @Autowired
    public AsyncRestTemplate asyncRestTemplate; @Autowired
    public PoolingNHttpClientConnectionManager poolingNHttpClientConnectionManager; @Autowired
    public ProtocolRegistry protocolRegistry; }
@Test public void getRequestHeadersWithoutUrl() { HttpHeaders httpHeaders = ngsiClient.getRequestHeaders(); assertEquals(MediaType.APPLICATION_XML, httpHeaders.getContentType()); assertTrue(httpHeaders.getAccept().contains(MediaType.APPLICATION_XML)); }
@Test public void getRequestHeadersWithNullUrl() { HttpHeaders httpHeaders = ngsiClient.getRequestHeaders(null); assertEquals(MediaType.APPLICATION_XML, httpHeaders.getContentType()); assertTrue(httpHeaders.getAccept().contains(MediaType.APPLICATION_XML)); }
@Test public void getRequestHeadersWithUrlXml() { when(protocolRegistry.supportXml(any())).thenReturn(true); when(protocolRegistry.supportV1Json(any())).thenReturn(false); HttpHeaders httpHeaders = ngsiClient.getRequestHeaders("localhost"); assertEquals(MediaType.APPLICATION_XML, httpHeaders.getContentType()); assertTrue(httpHeaders.getAccept().contains(MediaType.APPLICATION_XML)); }
@Test public void getRequestHeadersWithUrlV1Json() { when(protocolRegistry.supportXml(any())).thenReturn(false); when(protocolRegistry.supportV1Json(any())).thenReturn(true); HttpHeaders httpHeaders = ngsiClient.getRequestHeaders("localhost"); assertEquals(MediaType.APPLICATION_JSON, httpHeaders.getContentType()); assertTrue(httpHeaders.getAccept().contains(MediaType.APPLICATION_JSON)); }
@Test public void getRequestHeadersWithUrlV2Json() { when(protocolRegistry.supportXml(any())).thenReturn(false); when(protocolRegistry.supportV1Json(any())).thenReturn(false); HttpHeaders httpHeaders = ngsiClient.getRequestHeaders("localhost"); assertEquals(MediaType.APPLICATION_JSON, httpHeaders.getContentType()); assertTrue(httpHeaders.getAccept().contains(MediaType.APPLICATION_JSON)); }