javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClientTest.java
1.1 --- a/javaquery/demo-twitter/src/test/java/org/apidesign/bck2brwsr/demo/twitter/TwitterClientTest.java Tue Feb 11 10:48:24 2014 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,67 +0,0 @@
1.4 -/**
1.5 - * Back 2 Browser Bytecode Translator
1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.7 - *
1.8 - * This program is free software: you can redistribute it and/or modify
1.9 - * it under the terms of the GNU General Public License as published by
1.10 - * the Free Software Foundation, version 2 of the License.
1.11 - *
1.12 - * This program is distributed in the hope that it will be useful,
1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 - * GNU General Public License for more details.
1.16 - *
1.17 - * You should have received a copy of the GNU General Public License
1.18 - * along with this program. Look for COPYING file in the top folder.
1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
1.20 - */
1.21 -package org.apidesign.bck2brwsr.demo.twitter;
1.22 -
1.23 -import java.util.List;
1.24 -import static org.testng.Assert.*;
1.25 -import org.testng.annotations.BeforeMethod;
1.26 -import org.testng.annotations.Test;
1.27 -
1.28 -/** We can unit test the TwitterModel smoothly.
1.29 - *
1.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
1.31 - */
1.32 -public class TwitterClientTest {
1.33 - private TwitterModel model;
1.34 -
1.35 -
1.36 - @BeforeMethod
1.37 - public void initModel() {
1.38 - model = new TwitterModel().applyBindings();
1.39 - }
1.40 -
1.41 - @Test public void testIsValidToAdd() {
1.42 - model.setUserNameToAdd("Joe");
1.43 - Tweeters t = new Tweeters();
1.44 - t.setName("test");
1.45 - model.getSavedLists().add(t);
1.46 - model.setActiveTweetersName("test");
1.47 -
1.48 - assertTrue(model.isUserNameToAddIsValid(), "Joe is OK");
1.49 - TwitterClient.addUser(model);
1.50 - assertFalse(model.isUserNameToAddIsValid(), "Can't add Joe for the 2nd time");
1.51 - assertEquals(t.getUserNames().size(), 0, "Original tweeters list remains empty");
1.52 -
1.53 - List<String> mod = model.getActiveTweeters();
1.54 - assertTrue(model.isHasUnsavedChanges(), "We have modifications");
1.55 - assertEquals(mod.size(), 1, "One element in the list");
1.56 - assertEquals(mod.get(0), "Joe", "Its name is Joe");
1.57 -
1.58 - assertSame(model.getActiveTweeters(), mod, "Editing list is the modified one");
1.59 -
1.60 - TwitterClient.saveChanges(model);
1.61 - assertFalse(model.isHasUnsavedChanges(), "Does not have anything to save");
1.62 -
1.63 - assertSame(model.getActiveTweeters(), mod, "Still editing the old modified one");
1.64 - }
1.65 -
1.66 - @Test public void httpAtTheEnd() {
1.67 - String res = TwitterClient.Twt.html("Ahoj http://kuk");
1.68 - assertEquals(res, "Ahoj <a href='http://kuk'>http://kuk</a>");
1.69 - }
1.70 -}