Skip to content

Commit

Permalink
Modified according to rick's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
garyluoex committed Jan 18, 2017
1 parent 9fbf86e commit 2104fd0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.fasterxml.jackson.annotation.JsonValue;

/**
* An interface for tag.
* Interface for tags used for tagging dimension fields to add additional properties implicitly specified by its name.
*/
public interface Tag {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import java.util.Set;

/**
* Dimension field with tags.
* Interface for Dimension fields that expects unique tags to be attached to it to add expressiveness.
*/
public interface TaggedDimensionField extends DimensionField {

/**
* Get a list of tags associated to the current field.
* Get a set of tags associated to the current field.
*
* @return a list of tags
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
package com.yahoo.bard.webservice.data.dimension.impl;

import com.yahoo.bard.webservice.data.dimension.Tag;

import java.util.Locale;
import com.yahoo.bard.webservice.util.EnumUtils;

/**
* Default dimension field tag provided in fili-navi to match fili-core concept "key" field.
* Default dimension field tag provided to match fili core concepts.
*/
public enum DefaultDimensionFieldTag implements Tag {
/**
* Dimension field tag to match fili concept of a "key" field.
*/
PRIMARY_KEY
;

Expand All @@ -19,7 +21,7 @@ public enum DefaultDimensionFieldTag implements Tag {
* Constructor, build name using camel cased enum name.
*/
DefaultDimensionFieldTag() {
this.tagName = name().toLowerCase(Locale.ENGLISH);
this.tagName = EnumUtils.camelCase(name());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TaggedDimensionFieldSpec extends Specification {
objectMapper = new ObjectMapper()

mockTag = Mock(Tag)
mockTag.getName() >> "mock_tag"
mockTag.getName() >> "mockTag"

noTagField = TEST_NO_TAG
oneTagField = TEST_ONE_TAG
Expand All @@ -46,7 +46,7 @@ class TaggedDimensionFieldSpec extends Specification {
def "Tagged dimension fields serialize as expected"() {
expect:
objectMapper.writeValueAsString(noTagField) == '{"name":"testNoTag","tags":[],"description":"testNoTag description"}'
objectMapper.writeValueAsString(oneTagField) == '{"name":"testOneTag","tags":["primary_key"],"description":"testOneTag description"}'
objectMapper.writeValueAsString(twoTagField) == '{"name":"testTwoTag","tags":["primary_key","mock_tag"],"description":"testTwoTag description"}'
objectMapper.writeValueAsString(oneTagField) == '{"name":"testOneTag","tags":["primaryKey"],"description":"testOneTag description"}'
objectMapper.writeValueAsString(twoTagField) == '{"name":"testTwoTag","tags":["primaryKey","mockTag"],"description":"testTwoTag description"}'
}
}

0 comments on commit 2104fd0

Please sign in to comment.