<div dir="ltr">Hi,<div><br></div><div>I agree w/ Erik - however, I think the test has a bug, if the installations are not directly associated with a Variant. Should be easy to fix.</div><div><br></div><div>BTW. qmx, you mentioned the &quot;<span style="font-size:12.8000001907349px">setDeviceType()&quot;, but that is really just plain text metadata, like here:</span></div><div><a href="https://github.com/aerogear/aerogear-push-helloworld/blob/master/ios/HelloWorld/AGAppDelegate.m#L106">https://github.com/aerogear/aerogear-push-helloworld/blob/master/ios/HelloWorld/AGAppDelegate.m#L106</a> </div><div><br></div><div>The validator is triggered by the actual variant type (installation<span style="font-size:12.8000001907349px">.getVariant().</span><span style="font-size:12.8000001907349px">getType())</span></div><div><br></div><div>-Matthias</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 13, 2015 at 8:17 AM, Erik Jan de Wit <span dir="ltr">&lt;<a href="mailto:edewit@redhat.com" target="_blank">edewit@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Don’t know if it’s really a bug, but in order to validate that a device token is valid we need to know what variant type it belongs to. It makes no sense for a installation to be persisted without a Variant, because then you cannot send any messages to that device. So if you try to persist a installation without a variant the device token is not valid seems to be to be a valid statement.<br>
<br>
This was introduced when we added cordova, there it’s easy to make a mistake and have the wrong variantID / secret in your settings. Resulting in a iOS device registering under an android variant. With the deviceToken validation this can no longer happen.<br>
<br>
Does this make sense?<br>
<br>
Cheers,<br>
        Erik Jan<br>
<div class="HOEnZb"><div class="h5"><br>
On 13 Feb,2015, at 2:02 , Douglas Campos &lt;<a href="mailto:qmx@qmx.me">qmx@qmx.me</a>&gt; wrote:<br>
<br>
&gt; Howdy!<br>
&gt;<br>
&gt; I was doing the migration work and found out something funny:<br>
&gt;<br>
&gt; For Installations, we have `installation.setDeviceType()`, but during<br>
&gt; Installation `persist()`, the DeviceTokenValidator is called, which in<br>
&gt; turn looks for a Variant.<br>
&gt;<br>
&gt; So after fiddling with some orm settings suddenly a bunch of tests<br>
&gt; started to break, which led me to this snippet[1]:<br>
&gt;<br>
&gt; // disabled<br>
&gt; Installation android3 = new Installation();<br>
&gt; android3.setAlias(&quot;<a href="mailto:foo@bar.org">foo@bar.org</a>&quot;);<br>
&gt; android3.setDeviceToken(&quot;543234234890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890&quot;);<br>
&gt; android3.setDeviceType(&quot;Android Tablet&quot;);<br>
&gt; android3.setEnabled(false);<br>
&gt;<br>
&gt; installationDao.create(android3);<br>
&gt;<br>
&gt; See, our tests are creating an installation without associating it to a<br>
&gt; variant first, then it blows up here[2]:<br>
&gt;<br>
&gt; // DeviceTokenValidator#isValid()<br>
&gt; if (installation.getVariant() == null || installation.getVariant().getType() == null || deviceToken == null) {<br>
&gt;    return false;<br>
&gt; }<br>
&gt;<br>
&gt; This is smelling like a bug to me - kinda like the validator wasn&#39;t<br>
&gt; actually running during tests. Am I crazy?<br>
&gt;<br>
&gt; [1]:<a href="https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/jpa/src/test/java/org/jboss/aerogear/unifiedpush/jpa/InstallationDaoTest.java#L133-L140" target="_blank">https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/jpa/src/test/java/org/jboss/aerogear/unifiedpush/jpa/InstallationDaoTest.java#L133-L140</a><br>
&gt; [2]:<a href="https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/api/src/main/java/org/jboss/aerogear/unifiedpush/api/validation/DeviceTokenValidator.java#L60" target="_blank">https://github.com/aerogear/aerogear-unifiedpush-server/blob/master/model/api/src/main/java/org/jboss/aerogear/unifiedpush/api/validation/DeviceTokenValidator.java#L60</a><br>
&gt;<br>
&gt; --<br>
&gt; qmx<br>
&gt; _______________________________________________<br>
&gt; aerogear-dev mailing list<br>
&gt; <a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
<br>
<br>
_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Matthias Wessendorf <br><br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a></div>
</div>