Skip to content

Commit

Permalink
KYLO-3122 datasourceIds property resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
scottreisdorf committed Nov 27, 2018
1 parent 31a1779 commit 3170464
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ private String getMetadataPropertyValue(FeedMetadata metadata, String variableNa
if(isCollectionOfStrings(obj)){
return stringCollectionToString((Collection<String>)obj);
}
else if(obj instanceof Collection && ((Collection)obj).isEmpty()){
return null;
}
else {
return obj.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.thinkbiganalytics.discovery.model.DefaultTableSchema;
import com.thinkbiganalytics.feedmgr.rest.model.FeedCategory;
import com.thinkbiganalytics.feedmgr.rest.model.FeedDataTransformation;
import com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata;
import com.thinkbiganalytics.feedmgr.rest.model.schema.TableSetup;
import com.thinkbiganalytics.nifi.rest.model.NifiProperty;
Expand All @@ -37,6 +38,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Nonnull;
import javax.inject.Inject;
Expand Down Expand Up @@ -108,6 +110,8 @@ public void testStrSubstitutor() {
public void resolveExpression() {
final FeedMetadata metadata = new FeedMetadata();
metadata.setSystemFeedName("myfeed");
metadata.setDataTransformation(new FeedDataTransformation());
metadata.getDataTransformation().setDatasourceIds(new ArrayList<>());

// Verify config variable
final NifiProperty prop1 = createProperty("${config.test.value}");
Expand Down Expand Up @@ -180,6 +184,16 @@ public void resolveExpression() {
Assert.assertTrue(resolver.resolveExpression(metadata, hiveSchema));
Assert.assertEquals("hive",hiveSchema.getValue());

// Verify datatransformation variables
final NifiProperty prop13 = createProperty("${metadata.dataTransformation.datasourceIds}");
Assert.assertFalse(resolver.resolveExpression(metadata, prop13));

String uuid =UUID.randomUUID().toString();
metadata.getDataTransformation().getDatasourceIds().add(uuid);
final NifiProperty prop14 = createProperty("${metadata.dataTransformation.datasourceIds}");
Assert.assertTrue(resolver.resolveExpression(metadata, prop14));
Assert.assertEquals(uuid, prop14.getValue());


}

Expand Down

0 comments on commit 3170464

Please sign in to comment.