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

[sleepiq] Tests failing #7981

Closed
lolodomo opened this issue Jun 22, 2020 · 4 comments · Fixed by #7983
Closed

[sleepiq] Tests failing #7981

lolodomo opened this issue Jun 22, 2020 · 4 comments · Fixed by #7983
Labels
bug An unexpected problem or unintended behavior of an add-on test

Comments

@lolodomo
Copy link
Contributor

Build on Windows 10:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.openhab.binding.sleepiq.api.model.BedSideStatusTest
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.185 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.BedSideStatusTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.BedSideStatusTest)  Time elapsed: 0.015 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "isInBed": false,
  "alertDetailedMessage": "No Alert",
  "sleepNumber": 55,
  "alertId": 0,
  "lastLink": "3 d 05:04:38",
] "pressure": 573
}> but was:<{[
  "isInBed": false,
  "alertDetailedMessage": "No Alert",
  "sleepNumber": 55,
  "alertId": 0,
  "lastLink": "3 d 05:04:38",
  "pressure": 573]
}>
        at org.openhab.binding.sleepiq.api.model.BedSideStatusTest.testSerializeAllFields(BedSideStatusTest.java:54)

[INFO] Running org.openhab.binding.sleepiq.api.model.BedsResponseTest
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.BedsResponseTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.BedsResponseTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "beds": [
    {
      "name": "Bed1"
    },
    {
      "name": "Bed2"
    }
] ]
}> but was:<{[
  "beds": [
    {
      "name": "Bed1"
    },
    {
      "name": "Bed2"
    }
  ]]
}>
        at org.openhab.binding.sleepiq.api.model.BedsResponseTest.testSerializeAllFields(BedsResponseTest.java:49)

[INFO] Running org.openhab.binding.sleepiq.api.model.BedStatusTest
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.BedStatusTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.BedStatusTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "status": 1,
  "bedId": "-9999999999999999999",
  "leftSide": {
    "isInBed": true
  },
  "rightSide": {
    "isInBed": false
] }
}> but was:<{[
  "status": 1,
  "bedId": "-9999999999999999999",
  "leftSide": {
    "isInBed": true
  },
  "rightSide": {
    "isInBed": false
  }]
}>
        at org.openhab.binding.sleepiq.api.model.BedStatusTest.testSerializeAllFields(BedStatusTest.java:51)

[INFO] Running org.openhab.binding.sleepiq.api.model.BedTest
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.006 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.BedTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.BedTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "registrationDate": "2017-02-17T02:14:10Z",
  "sleeperRightId": "-1111111111111111111",
  "base": "MODULAR",
  "returnRequestStatus": 0,
  "size": "QUEEN",
  "name": "Bed",
  "serial": "",
  "isKidsBed": false,
  "dualSleep": true,
  "bedId": "-9999999999999999999",
  "status": 1,
  "sleeperLeftId": "-2222222222222222222",
  "version": "",
  "accountId": "-8888888888888888888",
  "timezone": "US/Pacific",
  "model": "P5",
  "purchaseDate": "2017-02-02T00:00:01Z",
  "macAddress": "AABBCCDDEEFF",
  "sku": "QP5",
  "zipcode": "90210",
] "reference": "55555555555-5"
}> but was:<{[
  "registrationDate": "2017-02-17T02:14:10Z",
  "sleeperRightId": "-1111111111111111111",
  "base": "MODULAR",
  "returnRequestStatus": 0,
  "size": "QUEEN",
  "name": "Bed",
  "serial": "",
  "isKidsBed": false,
  "dualSleep": true,
  "bedId": "-9999999999999999999",
  "status": 1,
  "sleeperLeftId": "-2222222222222222222",
  "version": "",
  "accountId": "-8888888888888888888",
  "timezone": "US/Pacific",
  "model": "P5",
  "purchaseDate": "2017-02-02T00:00:01Z",
  "macAddress": "AABBCCDDEEFF",
  "sku": "QP5",
  "zipcode": "90210",
  "reference": "55555555555-5"]
}>
        at org.openhab.binding.sleepiq.api.model.BedTest.testSerializeAllFields(BedTest.java:80)

[INFO] Running org.openhab.binding.sleepiq.api.model.FamilyStatusTest
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.FamilyStatusTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.FamilyStatusTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "beds": [
    {
      "status": 1
    }
] ]
}> but was:<{[
  "beds": [
    {
      "status": 1
    }
  ]]
}>
        at org.openhab.binding.sleepiq.api.model.FamilyStatusTest.testSerializeAllFields(FamilyStatusTest.java:48)

[INFO] Running org.openhab.binding.sleepiq.api.model.PauseModeTest
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.PauseModeTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.PauseModeTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "accountId": "-8888888888888888888",
  "bedId": "-9999999999999999999",
] "pauseMode": "off"
}> but was:<{[
  "accountId": "-8888888888888888888",
  "bedId": "-9999999999999999999",
  "pauseMode": "off"]
}>
        at org.openhab.binding.sleepiq.api.model.PauseModeTest.testSerializeAllFields(PauseModeTest.java:46)

[INFO] Running org.openhab.binding.sleepiq.api.model.SleepersResponseTest
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.SleepersResponseTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.SleepersResponseTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "sleepers": [
    {
      "firstName": "Alice"
    },
    {
      "firstName": "Bob"
    }
] ]
}> but was:<{[
  "sleepers": [
    {
      "firstName": "Alice"
    },
    {
      "firstName": "Bob"
    }
  ]]
}>
        at org.openhab.binding.sleepiq.api.model.SleepersResponseTest.testSerializeAllFields(SleepersResponseTest.java:49)

[INFO] Running org.openhab.binding.sleepiq.api.model.SleeperTest
[ERROR] Tests run: 4, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0 s <<< FAILURE! - in org.openhab.binding.sleepiq.api.model.SleeperTest
[ERROR] testSerializeAllFields(org.openhab.binding.sleepiq.api.model.SleeperTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
  "firstName": "Alice",
  "active": true,
  "emailValidated": true,
  "isChild": false,
  "bedId": "-9999999999999999999",
  "birthYear": "1970",
  "zipCode": "90210",
  "timezone": "US/Pacific",
  "isMale": false,
  "weight": 110,
  "duration": "",
  "sleeperId": "-1111111111111111111",
  "height": 64,
  "licenseVersion": 6,
  "username": "[email protected]",
  "birthMonth": 6,
  "sleepGoal": 450,
  "isAccountOwner": true,
  "accountId": "-5555555555555555555",
  "email": "[email protected]",
  "avatar": "",
  "lastLogin": "2017-02-17 20:19:36 CST",
] "side": 1
}> but was:<{[
  "firstName": "Alice",
  "active": true,
  "emailValidated": true,
  "isChild": false,
  "bedId": "-9999999999999999999",
  "birthYear": "1970",
  "zipCode": "90210",
  "timezone": "US/Pacific",
  "isMale": false,
  "weight": 110,
  "duration": "",
  "sleeperId": "-1111111111111111111",
  "height": 64,
  "licenseVersion": 6,
  "username": "[email protected]",
  "birthMonth": 6,
  "sleepGoal": 450,
  "isAccountOwner": true,
  "accountId": "-5555555555555555555",
  "email": "[email protected]",
  "avatar": "",
  "lastLogin": "2017-02-17 20:19:36 CST",
  "side": 1]
}>
        at org.openhab.binding.sleepiq.api.model.SleeperTest.testSerializeAllFields(SleeperTest.java:66)

[ERROR] testSerializeLastLoginNull(org.openhab.binding.sleepiq.api.model.SleeperTest)  Time elapsed: 0 s  <<< FAILURE!
org.junit.ComparisonFailure:
expected:<{[
] "lastLogin": "null"
}> but was:<{[
  "lastLogin": "null"]
}>
        at org.openhab.binding.sleepiq.api.model.SleeperTest.testSerializeLastLoginNull(SleeperTest.java:73)

[INFO] Running org.openhab.binding.sleepiq.api.model.TimeSinceTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in org.openhab.binding.sleepiq.api.model.TimeSinceTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   BedSideStatusTest.testSerializeAllFields:54 expected:<{[
  "isInBed": false,
  "alertDetailedMessage": "No Alert",
  "sleepNumber": 55,
  "alertId": 0,
  "lastLink": "3 d 05:04:38",
] "pressure": 573
}> but was:<{[
  "isInBed": false,
  "alertDetailedMessage": "No Alert",
  "sleepNumber": 55,
  "alertId": 0,
  "lastLink": "3 d 05:04:38",
  "pressure": 573]
}>
[ERROR]   BedStatusTest.testSerializeAllFields:51 expected:<{[
  "status": 1,
  "bedId": "-9999999999999999999",
  "leftSide": {
    "isInBed": true
  },
  "rightSide": {
    "isInBed": false
] }
}> but was:<{[
  "status": 1,
  "bedId": "-9999999999999999999",
  "leftSide": {
    "isInBed": true
  },
  "rightSide": {
    "isInBed": false
  }]
}>
[ERROR]   BedTest.testSerializeAllFields:80 expected:<{[
  "registrationDate": "2017-02-17T02:14:10Z",
  "sleeperRightId": "-1111111111111111111",
  "base": "MODULAR",
  "returnRequestStatus": 0,
  "size": "QUEEN",
  "name": "Bed",
  "serial": "",
  "isKidsBed": false,
  "dualSleep": true,
  "bedId": "-9999999999999999999",
  "status": 1,
  "sleeperLeftId": "-2222222222222222222",
  "version": "",
  "accountId": "-8888888888888888888",
  "timezone": "US/Pacific",
  "model": "P5",
  "purchaseDate": "2017-02-02T00:00:01Z",
  "macAddress": "AABBCCDDEEFF",
  "sku": "QP5",
  "zipcode": "90210",
] "reference": "55555555555-5"
}> but was:<{[
  "registrationDate": "2017-02-17T02:14:10Z",
  "sleeperRightId": "-1111111111111111111",
  "base": "MODULAR",
  "returnRequestStatus": 0,
  "size": "QUEEN",
  "name": "Bed",
  "serial": "",
  "isKidsBed": false,
  "dualSleep": true,
  "bedId": "-9999999999999999999",
  "status": 1,
  "sleeperLeftId": "-2222222222222222222",
  "version": "",
  "accountId": "-8888888888888888888",
  "timezone": "US/Pacific",
  "model": "P5",
  "purchaseDate": "2017-02-02T00:00:01Z",
  "macAddress": "AABBCCDDEEFF",
  "sku": "QP5",
  "zipcode": "90210",
  "reference": "55555555555-5"]
}>
[ERROR]   BedsResponseTest.testSerializeAllFields:49 expected:<{[
  "beds": [
    {
      "name": "Bed1"
    },
    {
      "name": "Bed2"
    }
] ]
}> but was:<{[
  "beds": [
    {
      "name": "Bed1"
    },
    {
      "name": "Bed2"
    }
  ]]
}>
[ERROR]   FamilyStatusTest.testSerializeAllFields:48 expected:<{[
  "beds": [
    {
      "status": 1
    }
] ]
}> but was:<{[
  "beds": [
    {
      "status": 1
    }
  ]]
}>
[ERROR]   PauseModeTest.testSerializeAllFields:46 expected:<{[
  "accountId": "-8888888888888888888",
  "bedId": "-9999999999999999999",
] "pauseMode": "off"
}> but was:<{[
  "accountId": "-8888888888888888888",
  "bedId": "-9999999999999999999",
  "pauseMode": "off"]
}>
[ERROR]   SleeperTest.testSerializeAllFields:66 expected:<{[
  "firstName": "Alice",
  "active": true,
  "emailValidated": true,
  "isChild": false,
  "bedId": "-9999999999999999999",
  "birthYear": "1970",
  "zipCode": "90210",
  "timezone": "US/Pacific",
  "isMale": false,
  "weight": 110,
  "duration": "",
  "sleeperId": "-1111111111111111111",
  "height": 64,
  "licenseVersion": 6,
  "username": "[email protected]",
  "birthMonth": 6,
  "sleepGoal": 450,
  "isAccountOwner": true,
  "accountId": "-5555555555555555555",
  "email": "[email protected]",
  "avatar": "",
  "lastLogin": "2017-02-17 20:19:36 CST",
] "side": 1
}> but was:<{[
  "firstName": "Alice",
  "active": true,
  "emailValidated": true,
  "isChild": false,
  "bedId": "-9999999999999999999",
  "birthYear": "1970",
  "zipCode": "90210",
  "timezone": "US/Pacific",
  "isMale": false,
  "weight": 110,
  "duration": "",
  "sleeperId": "-1111111111111111111",
  "height": 64,
  "licenseVersion": 6,
  "username": "[email protected]",
  "birthMonth": 6,
  "sleepGoal": 450,
  "isAccountOwner": true,
  "accountId": "-5555555555555555555",
  "email": "[email protected]",
  "avatar": "",
  "lastLogin": "2017-02-17 20:19:36 CST",
  "side": 1]
}>
[ERROR]   SleeperTest.testSerializeLastLoginNull:73 expected:<{[
] "lastLogin": "null"
}> but was:<{[
  "lastLogin": "null"]
}>
[ERROR]   SleepersResponseTest.testSerializeAllFields:49 expected:<{[
  "sleepers": [
    {
      "firstName": "Alice"
    },
    {
      "firstName": "Bob"
    }
] ]
}> but was:<{[
  "sleepers": [
    {
      "firstName": "Alice"
    },
    {
      "firstName": "Bob"
    }
  ]]
}>
[INFO]
[ERROR] Tests run: 21, Failures: 9, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.872 s
[INFO] Finished at: 2020-06-22T18:20:02+02:00
[INFO] Final Memory: 38M/662M
[INFO] ------------------------------------------------------------------------
@lolodomo lolodomo added bug An unexpected problem or unintended behavior of an add-on test labels Jun 22, 2020
@lolodomo
Copy link
Contributor Author

lolodomo commented Jun 22, 2020

The problem is due to the fact that the JSON files contain \r\n at end of lines while gson.toJson(xxx) produces string with only \n at end of lines.
If I replace

    protected String readJson(String jsonFileName) throws IOException {
        return new String(Files.readAllBytes(getTestDataPath(jsonFileName)));
    }

by

    protected String readJson(String jsonFileName) throws IOException {
        return new String(Files.readAllBytes(getTestDataPath(jsonFileName))).replaceAll("\r\n", "\n");
    }

the problem is fixed.
But is it the correct way to go or should we update the 9 JSON files provided as expected results to replace \r\n by \n ?

lolodomo added a commit to lolodomo/openhab-addons that referenced this issue Jun 22, 2020
@lolodomo
Copy link
Contributor Author

file *
bed.json:                    ASCII text, with CRLF line terminators
bed-side-status.json:        ASCII text, with CRLF line terminators
beds-response.json:          ASCII text, with CRLF line terminators
bed-status.json:             ASCII text, with CRLF line terminators
family-status.json:          ASCII text, with CRLF line terminators
pause-mode.json:             ASCII text, with CRLF line terminators
sleeper.json:                ASCII text, with CRLF line terminators
sleeper-lastlogin-null.json: ASCII text, with CRLF line terminators
sleepers-response.json:      ASCII text, with CRLF line terminators

@lolodomo
Copy link
Contributor Author

So the files are Windows style files (CRLF) while Gson uses Unix style with only LF.

@lolodomo
Copy link
Contributor Author

@wborn : you are, I believe, the one who introduced these files with PR #7562 . Can we have your advice on how fixing the problem?

@cweitkamp cweitkamp changed the title {sleepiq] Tests failing [sleepiq] Tests failing Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on test
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant