1.1 --- a/twitter/src/test/java/org/apidesign/html/demo/twitter/TwitterClientTest.java Fri Dec 20 08:24:57 2013 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,73 +0,0 @@
1.4 -/**
1.5 - * The MIT License (MIT)
1.6 - *
1.7 - * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.8 - *
1.9 - * Permission is hereby granted, free of charge, to any person obtaining a copy
1.10 - * of this software and associated documentation files (the "Software"), to deal
1.11 - * in the Software without restriction, including without limitation the rights
1.12 - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1.13 - * copies of the Software, and to permit persons to whom the Software is
1.14 - * furnished to do so, subject to the following conditions:
1.15 - *
1.16 - * The above copyright notice and this permission notice shall be included in
1.17 - * all copies or substantial portions of the Software.
1.18 - *
1.19 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1.20 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1.21 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1.22 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1.23 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1.24 - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1.25 - * THE SOFTWARE.
1.26 - */
1.27 -package org.apidesign.html.demo.twitter;
1.28 -
1.29 -import java.util.List;
1.30 -import static org.testng.Assert.*;
1.31 -import org.testng.annotations.BeforeMethod;
1.32 -import org.testng.annotations.Test;
1.33 -
1.34 -/** We can unit test the TwitterModel smoothly.
1.35 - *
1.36 - * @author Jaroslav Tulach <jtulach@netbeans.org>
1.37 - */
1.38 -public class TwitterClientTest {
1.39 - private TwitterModel model;
1.40 -
1.41 -
1.42 - @BeforeMethod
1.43 - public void initModel() {
1.44 - model = new TwitterModel();
1.45 - }
1.46 -
1.47 - @Test public void testIsValidToAdd() {
1.48 - model.setUserNameToAdd("Joe");
1.49 - Tweeters t = new Tweeters();
1.50 - t.setName("test");
1.51 - model.getSavedLists().add(t);
1.52 - model.setActiveTweetersName("test");
1.53 -
1.54 - assertTrue(model.isUserNameToAddIsValid(), "Joe is OK");
1.55 - TwitterClient.addUser(model);
1.56 - assertFalse(model.isUserNameToAddIsValid(), "Can't add Joe for the 2nd time");
1.57 - assertEquals(t.getUserNames().size(), 0, "Original tweeters list remains empty");
1.58 -
1.59 - List<String> mod = model.getActiveTweeters();
1.60 - assertTrue(model.isHasUnsavedChanges(), "We have modifications");
1.61 - assertEquals(mod.size(), 1, "One element in the list");
1.62 - assertEquals(mod.get(0), "Joe", "Its name is Joe");
1.63 -
1.64 - assertSame(model.getActiveTweeters(), mod, "Editing list is the modified one");
1.65 -
1.66 - TwitterClient.saveChanges(model);
1.67 - assertFalse(model.isHasUnsavedChanges(), "Does not have anything to save");
1.68 -
1.69 - assertSame(model.getActiveTweeters(), mod, "Still editing the old modified one");
1.70 - }
1.71 -
1.72 - @Test public void httpAtTheEnd() {
1.73 - String res = TwitterClient.Twt.html("Ahoj http://kuk");
1.74 - assertEquals(res, "Ahoj <a href='http://kuk'>http://kuk</a>");
1.75 - }
1.76 -}