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