My original plan was the following: On client-side a call to a
Java-function is made here: [1]
This Java function should validate the input and returns an error if the
input is invalid. So one could do the validation there. However, you can
implement the validation on client-side directly as well, if you want.
But I see no problem with doing it on the Java-side. Usually, in an web
application, you dont want this because of the response time due to the
HTTP-Request, but we dont have that problem...
If you have questions about the JavaScript code, feel free to ask!

Best,
    Basti

[1]
https://github.com/saros-project/saros/blob/master/de.fu_berlin.inf.dpp.ui.frontend/html/js/views/add-contact-dialog.js#L64

Am 11/11/15 um 10:26 schrieb Matthias Bohnstedt:
> While it's okay to fix it on the Java side, Stefan got a point it's
> might be more efficient to solve this in the JS world:
>
> The saros-state model [1] contain a collection of all contacts that
> are currently in the roster, and each contact [2] have a field "JID".
> So you can probably check if this JID is present before the Javaside
> is called. (I think this happens in the Javascript
> function addContact:function(jid, displayName) [3]). You can also
> right a Unit test in the JS world. If you going this way then you want
> to read the short guide for changing JS, especially the build chain
> for JS [4]  
>
> The pro of this is solution is, that the "backend" doesn't get called
> with "invalid" values. So you skip the long
> frontend->backend->frontend chain. 
>
> But after all this is purely a design decision
> <http://www.dict.cc/englisch-deutsch/decision.html> where to validate
> and check and react to such inputs. In the currents state most of the
> validation is done in the UI-project (mostly insides the browser
> functions). In my opinion it's only important that we have ONE common
> way to do handle errors (aka one place where the validation is
> happening) to avoid confusion and make debugging easier. Right now
> it's the UI.Project, so the Java approach works for me.
>
>
> [1]
> https://github.com/saros-project/saros/tree/master/de.fu_berlin.inf.dpp.ui.frontend/html/js/models/saros-state.js
>  
> [2]
> https://github.com/saros-project/saros/blob/master/de.fu_berlin.inf.dpp.ui.frontend/html/js/models/contact.js
> [3] 
> https://github.com/saros-project/saros/blob/master/de.fu_berlin.inf.dpp.ui.frontend/html/js/saros-api.js
> [4] http://www.saros-project.org/html-gui#building-the-javascript-application
>
> 2015-11-10 20:08 GMT+01:00 Stefan Rossbach <srossb...@arcor.de
> <mailto:srossb...@arcor.de>>:
>
>     I am still wondering what this test is supposed to test ?
>
>     Where did you applied your fix ? Java Side ?
>
>     Matthias already said it is better to fix this in the JavaScript
>     side.
>
>
>     On 10.11.2015 19:30, Matthias Bohnstedt wrote:
>>     Hi Mehmet, Hi Ahmet-Serda
>>
>>     be aware of what you actually want to test in your. You probably
>>     don't want to test the correct behaviour of our SMACK library or
>>     the rooster object itself, nether the Injecttion via
>>     Picocontainer, but your modified add contact function. You can
>>     mock all needed dependencies in your test  (F.e. State facade).
>>     Therefor we often use the Easymock library  [1]. 
>>
>>     An example of the usage be found here [2]. (Again not yet in the
>>     master, but an working example of an JUnit test  inside the UI -
>>     PROJECT that uses movkes). You can also do find some examples  in
>>     the saros - eclipse project just search for library usages.
>>
>>     Bests
>>     Matthias Bohnstedt
>>     [1] http://easymock.org/getting-started.html
>>     [2]
>>     
>> http://saros-build.imp.fu-berlin.de/gerrit/#/c/2749/11/de.fu_berlin.inf.dpp.ui/test/junit/de/fu_berlin/inf/dpp/ui/manager/ProjectListManagerTest.java
>>
>>
>>     -------- Ursprüngliche Nachricht --------
>>     Von: Mehmet Bayram <mehmetbay...@zedat.fu-berlin.de>
>>     <mailto:mehmetbay...@zedat.fu-berlin.de>
>>     Datum: 10.11.2015 17:36 (GMT+01:00)
>>     An: dpp-devel@lists.sourceforge.net
>>     <mailto:dpp-devel@lists.sourceforge.net>
>>     Betreff: [DPP-Devel] Bug 857
>>
>>     Greetings,
>>
>>     We work to fix this bug (http://sourceforge.net/p/dpp/bugs/857/)
>>     and would
>>     like to write some JUnit test cases.
>>     But we can't access the Roster.
>>
>>     We tried it like this:
>>
>>        @Test
>>         public void testAddContact() {
>>             PicoBuilder picoBuilder = new PicoBuilder(new
>>     CompositeInjection(
>>                 new ConstructorInjection(), new
>>     AnnotatedFieldInjection()))
>>                 .withCaching().withLifecycle();
>>             MutablePicoContainer container = picoBuilder.build();
>>             new HTMLUIContextFactory().createComponents(container);
>>             StateFacade stateFacade =
>>     container.getComponent(StateFacade.class);
>>             Connection connection = stateFacade.getConnectionService()
>>                 .getConnection();
>>             Roster roster = connection.getRoster();
>>
>>             try {
>>                 roster.createEntry("a...@def.ghi"
>>     <mailto:a...@def.ghi>, "AB C", null);
>>                 roster.createEntry("x...@def.ghi"
>>     <mailto:x...@def.ghi>, "XY Z", null);
>>             } catch (XMPPException e) {
>>                 // TODO Auto-generated catch block
>>             }
>>
>>     If we would have a roster object, we would not try to create it
>>     like above.
>>
>>     But if we try to create one, we get the following error:
>>
>>     
>> org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException:
>>     de.fu_berlin.inf.dpp.ui.core_facades.StateFacade has unsatisfied
>>     dependency: class
>>     de.fu_berlin.inf.dpp.communication.connection.ConnectionHandler among
>>     unsatisfiable dependencies: [[class
>>     de.fu_berlin.inf.dpp.communication.connection.ConnectionHandler,
>>     class
>>     de.fu_berlin.inf.dpp.net.xmpp.XMPPConnectionService, class
>>     de.fu_berlin.inf.dpp.account.XMPPAccountStore]] where
>>     org.picocontainer.DefaultPicoContainer@6513cf0:15<(empty) was the
>>     leaf
>>     container being asked for dependencies.
>>     at
>>     
>> org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:188)
>>     at
>>     
>> org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:110)
>>     at
>>     
>> org.picocontainer.injectors.ConstructorInjector.access$100(ConstructorInjector.java:51)
>>     at
>>     
>> org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:308)
>>     at
>>     
>> org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:268)
>>     at
>>     
>> org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:341)
>>     at
>>     
>> org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
>>     at
>>     
>> org.picocontainer.injectors.CompositeInjector.getComponentInstance(CompositeInjector.java:42)
>>     at
>>     
>> org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
>>     at
>>     
>> org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
>>     at
>>     org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
>>     at
>>     
>> org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:691)
>>     at
>>     
>> org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:645)
>>     at
>>     
>> org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:670)
>>     at
>>     
>> de.fu_berlin.inf.dpp.ui.core_facades.StateFacadeTest.testAddContact(StateFacadeTest.java:24)
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>     at java.lang.reflect.Method.invoke(Unknown Source)
>>     at
>>     
>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>>     at
>>     
>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>>     at
>>     
>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>>     at
>>     
>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>>     at
>>     
>> org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
>>     at
>>     
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
>>     at
>>     
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
>>     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
>>     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>>     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
>>     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>>     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
>>     at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>>     at
>>     
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>>     at
>>     
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>     at
>>     
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>     at
>>     
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>     at
>>     
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>     at
>>     
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>>
>>     any help would be appreciated.
>>
>>     Best regards
>>
>>     Ahmet-Serdar Karakaya
>>     Mehmet Bayram
>>
>>
>>     
>> ------------------------------------------------------------------------------
>>     _______________________________________________
>>     DPP-Devel mailing list
>>     DPP-Devel@lists.sourceforge.net
>>     <mailto:DPP-Devel@lists.sourceforge.net>
>>     https://lists.sourceforge.net/lists/listinfo/dpp-devel
>>
>>
>>     
>> ------------------------------------------------------------------------------
>>
>>
>>     _______________________________________________
>>     DPP-Devel mailing list
>>     DPP-Devel@lists.sourceforge.net
>>     <mailto:DPP-Devel@lists.sourceforge.net>
>>     https://lists.sourceforge.net/lists/listinfo/dpp-devel
>
>
>
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> DPP-Devel mailing list
> DPP-Devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dpp-devel

------------------------------------------------------------------------------
_______________________________________________
DPP-Devel mailing list
DPP-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dpp-devel

Reply via email to