@Override public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException, ConnectionException { return ImmutableSet.of(MetadataKeyBuilder.newKey("HARVESTED").build()); }
@Override public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException, ConnectionException { return ImmutableSet.of(MetadataKeyBuilder.newKey("APPLE").build()); }
@Override public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException, ConnectionException { return ImmutableSet.<MetadataKey>builder() .addAll(TestMetadataResolverUtils.getKeys(context)) .add(newKey(String.format(STARTED_KEY_MASK, STARTED)).build()) .build(); }
public static Set<MetadataKey> getKeys(MetadataContext context) throws ConnectionException { return context.getConnection().map(c -> { MetadataConnection connection = (MetadataConnection) c; return connection.getEntities().stream().map(e -> MetadataKeyBuilder.newKey(e).build()).collect(toSet()); }).orElse(emptySet()); }
@Override public Set<MetadataKey> getKeys(MetadataContext context) { return Arrays.stream(KeyIds.values()).map(e -> MetadataKeyBuilder.newKey(e.name()).build()).collect(Collectors.toSet()); }
private MetadataKey buildServiceKey(ForwardingSoapClient connection, WebServiceDefinition ws) { String serviceId = ws.getServiceId(); SoapMetadataResolver resolver = connection.getSoapClient(serviceId).getMetadataResolver(); MetadataKeyBuilder key = newKey(serviceId).withDisplayName(ws.getFriendlyName()); List<String> excludedOperations = ws.getExcludedOperations(); resolver.getAvailableOperations().stream() .filter(ope -> !excludedOperations.contains(ope)) .forEach(ope -> key.withChild(newKey(ope).withDisplayName(NameUtils.titleize(ope)))); return key.build(); } }
public static MetadataKey buildEuropeKey() { return newKey(EUROPE).withDisplayName(EUROPE).withChild(newKey(FRANCE).withChild(newKey(PARIS))).build(); }
public static MetadataKey buildEuropeKey() { return newKey(EUROPE).withDisplayName(EUROPE).withChild(newKey(FRANCE).withChild(newKey(PARIS))).build(); }
@Test public void getDsqlQueryAutomaticGeneratedOutputMetadata() throws Exception { location = QUERY_LOCATION; MetadataKey dsqlKey = newKey(DSQL_QUERY).build(); MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(dsqlKey); assertThat(entityMetadata.isSuccess(), is(true)); MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType(); assertThat(generatedType, is(instanceOf(ArrayType.class))); assertCircleType((ObjectType) ((ArrayType) generatedType).getType()); }
public static MetadataKey buildAmericaKey() { return newKey(AMERICA).withDisplayName(AMERICA) .withChild(newKey(ARGENTINA).withChild(newKey(BUENOS_AIRES)).withChild(newKey(LA_PLATA))) .withChild(newKey(USA).withDisplayName(USA_DISPLAY_NAME).withChild(newKey(SAN_FRANCISCO))).build(); }
public static MetadataKey buildAmericaKey() { return newKey(AMERICA).withDisplayName(AMERICA) .withChild(newKey(ARGENTINA).withChild(newKey(BUENOS_AIRES)).withChild(newKey(LA_PLATA))) .withChild(newKey(USA).withDisplayName(USA_DISPLAY_NAME).withChild(newKey(SAN_FRANCISCO))).build(); }
@Test public void failToGetMetadataWithMissingMetadataKeyLevels() throws Exception { assumeThat(resolutionType, is(ResolutionType.EXPLICIT_RESOLUTION)); location = builder().globalName(INCOMPLETE_MULTILEVEL_KEY_RESOLVER).addProcessorsPart().addIndexPart(0).build(); final MetadataKey metadataKey = newKey(AMERICA, CONTINENT).withChild(newKey(USA, COUNTRY)).build(); final MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = getComponentDynamicMetadata(metadataKey); assertMetadataFailure(result.getFailures().get(0), "Missing levels: [city]", INVALID_METADATA_KEY, "", COMPONENT); }
@Test public void getNativeQueryOutputArrayMetadata() throws Exception { location = builder().globalName(NATIVE_QUERY_LIST_FLOW).addProcessorsPart().addIndexPart(0).build(); MetadataKey nativeKey = newKey(NATIVE_QUERY).build(); MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(nativeKey); assertThat(entityMetadata.isSuccess(), is(true)); MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType(); assertThat(generatedType, is(instanceOf(ArrayType.class))); assertCircleType((ObjectType) ((ArrayType) generatedType).getType()); }
@Test public void failWithDynamicConfigurationWhenRetrievingMetadata() throws IOException { location = builder().globalName(RESOLVER_WITH_DYNAMIC_CONFIG).addProcessorsPart().addIndexPart(0).build(); MetadataKey key = newKey(AMERICA, CONTINENT).withChild(newKey(USA, COUNTRY).withChild(newKey(SAN_FRANCISCO, CITY))).build(); MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = getComponentDynamicMetadata(key); assertFailureResult(result, 1); assertMetadataFailure(result.getFailures().get(0), CONFIGURATION_CANNOT_BE_DYNAMIC, INVALID_CONFIGURATION, MetadataResolvingException.class.getName(), COMPONENT); }
@Test public void resolveMetadataWithNoRefDynamicConfig() throws Exception { location = builder().globalName(RESOLVER_WITH_IMPLICIT_DYNAMIC_CONFIG).addProcessorsPart().addIndexPart(0).build(); MetadataKey key = newKey(AMERICA).withChild(newKey(USA).withChild(newKey(SAN_FRANCISCO))).build(); final MetadataResult<ComponentMetadataDescriptor<OperationModel>> metadataResult = getComponentDynamicMetadata(key); assertFailureResult(metadataResult, 1); assertMetadataFailure(metadataResult.getFailures().get(0), "Configuration used for Metadata fetch cannot be dynamic", INVALID_CONFIGURATION, MetadataResolvingException.class.getName(), COMPONENT, ""); } }
@Test public void getNativeQueryOutputMetadata() throws Exception { location = builder().globalName(NATIVE_QUERY_FLOW).addProcessorsPart().addIndexPart(0).build(); MetadataKey nativeKey = newKey(NATIVE_QUERY).build(); MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(nativeKey); assertThat(entityMetadata.isSuccess(), is(true)); MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType(); assertCircleType((ObjectType) generatedType); }
@Test public void enumMetadataKey() throws IOException { location = Location.builder().globalName(ENUM_METADATA_KEY).addProcessorsPart().addIndexPart(0).build(); ComponentMetadataDescriptor metadataDescriptor = getSuccessComponentDynamicMetadata(newKey("MAMMAL").build()); final ComponentModel typedModel = metadataDescriptor.getModel(); assertExpectedType(getParameter(typedModel, "content"), TYPE_LOADER.load(Bear.class), true); }
@Test public void booleanMetadataKey() throws IOException { location = Location.builder().globalName(BOOLEAN_METADATA_KEY).addProcessorsPart().addIndexPart(0).build(); MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = metadataService.getOperationMetadata(location, newKey("true").build()); assertSuccessResult(result); assertExpectedType(getParameter(result.get().getModel(), "content"), TYPE_LOADER.load(SwordFish.class), true); }
@Test public void failToResolveWithMultipleChildren() throws MetadataResolvingException { exception.expect(MetadataResolvingException.class); exception.expectMessage("MetadataKey used for Metadata resolution must only have one child per level."); final MetadataKey invalidMetadataKey = newKey(AMERICA, CONTINENT) .withChild(newKey(USA, COUNTRY).withChild(newKey(SFO, CITY)).withChild(newKey(NY, CITY))).build(); setParameters(continentParam, countryParam, cityParam); setMetadataKeyIdModelProperty(LocationKey.class); keyIdObjectResolver = new MetadataKeyIdObjectResolver(componentModel); keyIdObjectResolver.resolve(invalidMetadataKey); }