### Question:
ServiceNowMetaDataExtension extends AbstractMetaDataExtension { @Override public Optional<MetaData> meta(Map<String, Object> parameters) { final String objectType = ConnectorOptions.extractOption(parameters, OBJECT_TYPE); final String metaType = ConnectorOptions.extractOption(parameters, META_TYPE, "definition"); if (ObjectHelper.equalIgnoreCase(objectType, ServiceNowConstants.RESOURCE_TABLE) && ObjectHelper.equalIgnoreCase(metaType, "definition")) { final MetaContext context = new MetaContext(parameters); ObjectHelper.notNull(context.getObjectType(), OBJECT_TYPE); ObjectHelper.notNull(context.getObjectName(), OBJECT_NAME); try { return tableDefinition(context); } catch (Exception e) { throw new IllegalStateException(e); } } if (ObjectHelper.equalIgnoreCase(objectType, ServiceNowConstants.RESOURCE_TABLE) && ObjectHelper.equalIgnoreCase(metaType, "list")) { final MetaContext context = new MetaContext(parameters); ObjectHelper.notNull(context.getObjectType(), OBJECT_TYPE); try { return tableList(context); } catch (Exception e) { throw new IllegalStateException(e); } } if (ObjectHelper.equalIgnoreCase(objectType, ServiceNowConstants.RESOURCE_IMPORT) && ObjectHelper.equalIgnoreCase(metaType, "list")) { final MetaContext context = new MetaContext(parameters); ObjectHelper.notNull(context.getObjectType(), OBJECT_TYPE); try { return importSetList(context); } catch (Exception e) { throw new IllegalStateException(e); } } throw new UnsupportedOperationException("Unsupported object type <" + objectType + ">"); } ServiceNowMetaDataExtension(CamelContext context); @Override Optional<MetaData> meta(Map<String, Object> parameters); static final String OBJECT_TYPE; static final String OBJECT_NAME; static final String META_TYPE; static final String TYPE; static final String ADDITIONAL_PROPERTIES; static final String ID; static final String SCHEMA; static final String TABLE; static final String SYS_DB_OBJECT; static final String NOW; static final String SYSPARM_EXCLUDE_REFERENCE_LINK; static final String SYSPARM_FIELDS; static final String SYSPARM_QUERY; }### Answer:
@Test public void retrieveTableListTes() { CamelContext context = new DefaultCamelContext(); ServiceNowMetaDataExtension extension = new ServiceNowMetaDataExtension(context); Map<String, Object> properties = new HashMap<>(); properties.put("instanceName", System.getProperty("servicenow.instance")); properties.put("userName", System.getProperty("servicenow.username")); properties.put("password", System.getProperty("servicenow.password")); properties.put("objectType", ServiceNowConstants.RESOURCE_TABLE); properties.put("metaType", "list"); Optional<MetaDataExtension.MetaData> meta = extension.meta(properties); assertThat(meta).isPresent(); assertThat(meta.get().getPayload()).isInstanceOf(JsonNode.class); assertThat(meta.get().getAttributes()).hasEntrySatisfying(MetaDataExtension.MetaData.JAVA_TYPE, new Condition<Object>() { @Override public boolean matches(Object val) { return Objects.equals(JsonNode.class, val); } }); assertThat(meta.get().getAttributes()).hasEntrySatisfying(MetaDataExtension.MetaData.CONTENT_TYPE, new Condition<Object>() { @Override public boolean matches(Object val) { return Objects.equals("application/json", val); } }); assertThat(meta.get().getAttributes()).hasEntrySatisfying("Meta-Context", new Condition<Object>() { @Override public boolean matches(Object val) { return Objects.equals("import", val); } }); }