@Test void applyShouldReturnNoResourceIfValueSelectorMatchesAnElementButThePropertySelectedByTheNameSlectorIsMissing() { ResourceCreatorConfiguration configuration = createSelectorTestConfiguration("$.missingName", "$.tmp"); CompiledResourceCreatorConfiguration compiledResourceCreatorConfiguration = new CompiledResourceCreatorConfiguration(configuration); TerraformResource terraformResource = mockSelectorTestResource("{ \"foo\": \"bar\", \"tmp\": { \"a\": 1, \"b\": 2, \"name\": \"i am a name\" } }"); Collection<VirtualTerraformResource> results = compiledResourceCreatorConfiguration.apply(terraformResource); assertThat(results).isEmpty(); }
public Collection<VirtualTerraformResource> apply(TerraformResource resource) { Object values; try { values = valuesPath.read(resource.getValues()); } catch (PathNotFoundException e) { return Collections.emptyList(); } if (values instanceof List) { return createResource(resource, (List<?>)values); } List<Object> valueList = new ArrayList<>(); valueList.add(values); return createResource(resource, valueList); }
CompiledResourceCreatorConfiguration { public Collection<VirtualTerraformResource> apply(TerraformResource resource) { Object values; try { values = valuesPath.read(resource.getValues()); } catch (PathNotFoundException e) { return Collections.emptyList(); } if (values instanceof List) { return createResource(resource, (List<?>)values); } List<Object> valueList = new ArrayList<>(); valueList.add(values); return createResource(resource, valueList); } }
CompiledResourceCreatorConfiguration { public Collection<VirtualTerraformResource> apply(TerraformResource resource) { Object values; try { values = valuesPath.read(resource.getValues()); } catch (PathNotFoundException e) { return Collections.emptyList(); } if (values instanceof List) { return createResource(resource, (List<?>)values); } List<Object> valueList = new ArrayList<>(); valueList.add(values); return createResource(resource, valueList); } CompiledResourceCreatorConfiguration(ResourceCreatorConfiguration resourceCreatorConfiguration); }
CompiledResourceCreatorConfiguration { public Collection<VirtualTerraformResource> apply(TerraformResource resource) { Object values; try { values = valuesPath.read(resource.getValues()); } catch (PathNotFoundException e) { return Collections.emptyList(); } if (values instanceof List) { return createResource(resource, (List<?>)values); } List<Object> valueList = new ArrayList<>(); valueList.add(values); return createResource(resource, valueList); } CompiledResourceCreatorConfiguration(ResourceCreatorConfiguration resourceCreatorConfiguration); boolean matches(TerraformResource resource); Collection<VirtualTerraformResource> apply(TerraformResource resource); }
CompiledResourceCreatorConfiguration { public Collection<VirtualTerraformResource> apply(TerraformResource resource) { Object values; try { values = valuesPath.read(resource.getValues()); } catch (PathNotFoundException e) { return Collections.emptyList(); } if (values instanceof List) { return createResource(resource, (List<?>)values); } List<Object> valueList = new ArrayList<>(); valueList.add(values); return createResource(resource, valueList); } CompiledResourceCreatorConfiguration(ResourceCreatorConfiguration resourceCreatorConfiguration); boolean matches(TerraformResource resource); Collection<VirtualTerraformResource> apply(TerraformResource resource);  }