Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved coverage for JsonUtils #73

Merged

Conversation

sravanthi-konduru
Copy link
Contributor

Improve code coverage for JsonUtils
Related issues
N/A

Describe the proposed solution
Added tests for yaml mapper and file parsing

Describe alternatives you've considered
N/A

Additional context
N/A

@salesforce-cla
Copy link

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Sravanthi Konduru <s***@s***.i***.s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce.com Contributor License Agreement and this Pull Request will be revalidated.

@sravanthi-konduru sravanthi-konduru force-pushed the unittest/jsonutils-coverage branch 2 times, most recently from 3df1a8f to 5f60077 Compare August 21, 2018 12:41
@codecov
Copy link

codecov bot commented Aug 21, 2018

Codecov Report

Merging #73 into master will increase coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #73      +/-   ##
==========================================
+ Coverage   85.88%   85.97%   +0.08%     
==========================================
  Files         294      294              
  Lines        9530     9530              
  Branches      320      535     +215     
==========================================
+ Hits         8185     8193       +8     
+ Misses       1345     1337       -8
Impacted Files Coverage Δ
...es/src/main/scala/com/salesforce/op/OpParams.scala 85.41% <0%> (-4.17%) ⬇️
...scala/com/salesforce/op/utils/json/JsonUtils.scala 82.35% <0%> (+29.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b816e66...b1accb4. Read the comment docs.

@salesforce-cla
Copy link

Thanks for the contribution! It looks like @sravanthi-konduru is an internal user so signing the CLA is not required. However, we need to confirm this.

@jamesward
Copy link
Contributor

@sravanthi-konduru I've invited you to: https://github.com/salesforce

Once accepted, refresh the status of the CLA: https://cla.salesforce.com/status/salesforce/TransmogrifAI/pull/73


case class Address(city: String, state: String)

private object Format extends Enumeration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to reate enum. Simple create two check function: checkYaml and checkJson

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

forAll(doubles) { d => check(TestDouble(d, Array.empty, Seq.empty, Map.empty, None), Format.Yaml) }
}

property(testName = "handle json file reading properly") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Simply do: property(“read json file”)

def check(data: TestDouble): Unit = {
val json = JsonUtils.toJsonString(data)
JsonUtils.fromString[TestDouble](json) match {
property(testName = "handle yml file reading properly") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

property(“read yaml file”)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -0,0 +1,7 @@
{
"name": "Alvin Alexander",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a random name? Lets just put name “Foo Bar”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is random. Updated to Foo Bar!

val person = Person("Foo Bar", Address("Talkeetna", "AK"))
JsonUtils.fromFile[Person](ymlFile) match {
case Failure(e) => fail(e)
case Success(value) => assert(value, person)
Copy link
Collaborator

Choose a reason for hiding this comment

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

since it's a case class you dont need a special assertion method but you can use the equality directly, i.e value shouldBe person - http:https://www.alessandrolacava.com/blog/scala-case-classes-in-depth/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know that.Thanks. Updated!

Copy link
Collaborator

@tovbinm tovbinm left a comment

Choose a reason for hiding this comment

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

one las comment left, otherwise lgtm

@tovbinm tovbinm merged commit 4a7db6f into salesforce:master Aug 22, 2018
ericwayman pushed a commit that referenced this pull request Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants