Skip to content

Conversation

@mikeproeng37
Copy link
Contributor

@mikeproeng37 mikeproeng37 commented Aug 15, 2018

Introduces a Builder class for the ProjectConfig entity and moves construction of it out of the main Optimizely class.

Adds a check to ensure that we cannot initialize the ProjectConfig with newer datafile versions.

https://optimizely.atlassian.net/browse/OASIS-3464

Mike Ng added 2 commits August 15, 2018 15:56
@coveralls
Copy link

coveralls commented Aug 16, 2018

Pull Request Test Coverage Report for Build 579

  • 17 of 18 (94.44%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 89.41%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core-api/src/main/java/com/optimizely/ab/config/ProjectConfig.java 14 15 93.33%
Totals Coverage Status
Change from base Build 573: 0.04%
Covered Lines: 2347
Relevant Lines: 2625

💛 - Coveralls

Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving but I had one question/concern about locking us out of future datafile versions.

"Please use a version 2 or 3 datafile with this SDK.");
}

if (Integer.parseInt(projectConfig.getVersion()) > Integer.parseInt(Version.V4.version)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary?

}

/**
* @return a {@link ProjectConfig} instance given a json string datafile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. JSON

if (datafile == null) {
throw new ConfigParseException("Unable to parse null datafile.");
}
if (datafile.length() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use isEmpty?

"Please use a version 2 or 3 datafile with this SDK.");
}

if (Integer.parseInt(projectConfig.getVersion()) > Integer.parseInt(Version.V4.version)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't rely on datafile version being integer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather just create a list of supported and unsupported datafile versions.

Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address comments before merging.

import com.optimizely.ab.error.NoOpErrorHandler;
import com.optimizely.ab.error.RaiseExceptionErrorHandler;
import com.optimizely.ab.internal.ControlAttribute;
import com.optimizely.ab.config.parser.DefaultConfigParser;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Alphabetize

}

private static final List<String> supportedVersions = Arrays.asList(
Version.V2.version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Indentation seems off. I think we have 4 spaces going on.

}

@Test
public void withInvalidNewerDatafile() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. We can just say withInvalidDatafile or better withUnsupportedDatafile

@mikeproeng37 mikeproeng37 merged commit 3157861 into master Aug 20, 2018
@mikeproeng37 mikeproeng37 deleted the mng/throw-on-newer-datafile-version branch September 21, 2018 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants