### Question:
ODataMetadata implements ODataConstants { public Set<String> getEntityNames() { return entityNames; }  boolean hasEntityProperties(); Set<PropertyMetadata> getEntityProperties(); void addEntityProperty(PropertyMetadata property); void setEntityProperties(Set<PropertyMetadata> properties); boolean hasEntityNames(); Set<String> getEntityNames(); void setEntityNames(Set<String> names);  }### Answer:
@Test public void testMetaDataExtensionRetrieval() throws Exception { ODataMetaDataExtension extension = new ODataMetaDataExtension(context); Map<String, Object> parameters = new HashMap<>(); parameters.put(SERVICE_URI, odataTestServer.getServiceUri()); Optional<MetaDataExtension.MetaData> meta = extension.meta(parameters); assertThat(meta).isPresent(); Object payload = meta.get().getPayload(); assertThat(payload).isInstanceOf(ODataMetadata.class); ODataMetadata odataMetadata = (ODataMetadata) payload; assertThat(odataMetadata.getEntityNames().size()).isEqualTo(3); assertThat(odataMetadata.getEntityNames()).contains(MANUFACTURERS, CARS, DRIVERS); }
@Test public void testMetaDataExtensionRetrievalSSL() throws Exception { ODataMetaDataExtension extension = new ODataMetaDataExtension(context); Map<String, Object> parameters = new HashMap<>(); parameters.put(SERVICE_URI, sslTestServer.getSecuredServiceUri()); parameters.put(SERVER_CERTIFICATE, Certificates.TEST_SERVICE.get()); Optional<MetaDataExtension.MetaData> meta = extension.meta(parameters); assertThat(meta).isPresent(); Object payload = meta.get().getPayload(); assertThat(payload).isInstanceOf(ODataMetadata.class); ODataMetadata odataMetadata = (ODataMetadata) payload; assertThat(odataMetadata.getEntityNames().size()).isEqualTo(3); assertThat(odataMetadata.getEntityNames()).contains(MANUFACTURERS, CARS, DRIVERS); }
@Test public void testMetaDataExtensionRetrieval() throws Exception { ODataMetaDataExtension extension = new ODataMetaDataExtension(context); Map<String, Object> parameters = new HashMap<>(); parameters.put(SERVICE_URI, defaultTestServer.servicePlainUri()); Optional<MetaDataExtension.MetaData> meta = extension.meta(parameters); assertThat(meta).isPresent(); Object payload = meta.get().getPayload(); assertThat(payload).isInstanceOf(ODataMetadata.class); ODataMetadata odataMetadata = (ODataMetadata) payload; assertThat(odataMetadata.getEntityNames().size()).isEqualTo(1); assertThat(odataMetadata.getEntityNames().iterator().next()).isEqualTo(defaultTestServer.resourcePath()); }
@Test public void testMetaDataExtensionRetrievalSSL() throws Exception { ODataMetaDataExtension extension = new ODataMetaDataExtension(context); Map<String, Object> parameters = new HashMap<>(); parameters.put(SERVICE_URI, sslTestServer.serviceSSLUri()); parameters.put(SERVER_CERTIFICATE, ODataTestServer.serverCertificate()); Optional<MetaDataExtension.MetaData> meta = extension.meta(parameters); assertThat(meta).isPresent(); Object payload = meta.get().getPayload(); assertThat(payload).isInstanceOf(ODataMetadata.class); ODataMetadata odataMetadata = (ODataMetadata) payload; assertThat(odataMetadata.getEntityNames().size()).isEqualTo(1); assertThat(odataMetadata.getEntityNames().iterator().next()).isEqualTo(sslTestServer.resourcePath()); }
@Test public void testMetaDataExtensionRetrievalOnceResourcePathSet() throws Exception { ODataMetaDataExtension extension = new ODataMetaDataExtension(context); Map<String, Object> parameters = new HashMap<>(); parameters.put(SERVICE_URI, defaultTestServer.servicePlainUri()); parameters.put(RESOURCE_PATH, "Products"); Optional<MetaDataExtension.MetaData> meta = extension.meta(parameters); assertThat(meta).isPresent(); Object payload = meta.get().getPayload(); assertThat(payload).isInstanceOf(ODataMetadata.class); ODataMetadata odataMetadata = (ODataMetadata) payload; assertThat(odataMetadata.getEntityNames().size()).isEqualTo(1); assertThat(odataMetadata.getEntityNames().iterator().next()).isEqualTo(defaultTestServer.resourcePath()); }