[aerogear-dev] UPS bug - am I crazy?

Douglas Campos qmx at qmx.me
Thu Feb 12 20:02:18 EST 2015


Howdy!

I was doing the migration work and found out something funny:

For Installations, we have `installation.setDeviceType()`, but during
Installation `persist()`, the DeviceTokenValidator is called, which in
turn looks for a Variant.

So after fiddling with some orm settings suddenly a bunch of tests
started to break, which led me to this snippet[1]:

// disabled
Installation android3 = new Installation();
android3.setAlias("foo at bar.org");
android3.setDeviceToken("543234234890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
android3.setDeviceType("Android Tablet");
android3.setEnabled(false);

installationDao.create(android3);

See, our tests are creating an installation without associating it to a
variant first, then it blows up here[2]:

// DeviceTokenValidator#isValid()
if (installation.getVariant() == null || installation.getVariant().getType() == null || deviceToken == null) {
    return false;
}

This is smelling like a bug to me - kinda like the validator wasn't
actually running during tests. Am I crazy?

[1]:https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/jpa/src/test/java/org/jboss/aerogear/unifiedpush/jpa/InstallationDaoTest.java#L133-L140
[2]:https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/api/src/main/java/org/jboss/aerogear/unifiedpush/api/validation/DeviceTokenValidator.java#L60

-- 
qmx


More information about the aerogear-dev mailing list