Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9097f005 authored by Stefan Niedermann's avatar Stefan Niedermann
Browse files

Add some basic JUnit Tests

parent 9db8e1ce
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
package it.niedermann.owncloud.notes.model;

import junit.framework.TestCase;

import java.util.Calendar;

/**
 * Tests the Note Model
 * Created by stefan on 06.10.15.
 */
public class NoteTest extends TestCase {

    public void testMarkDownStrip() {
        Note note = new Note(0, Calendar.getInstance(), "#Title", "");
        assertTrue("Title".equals(note.getTitle()));
        note.setTitle("* Aufzählung");
        assertTrue("Aufzählung".equals(note.getTitle()));
    }

    public void testMarkDownRendering() {
        Note note = new Note(0, Calendar.getInstance(), "", "**bold**");
        System.out.println(note.getHtmlContent());
        assertTrue(note.getHtmlContent().contains("<strong>bold</strong>"));
    }
}
+23 −0
Original line number Diff line number Diff line
package it.niedermann.owncloud.notes.util;

import junit.framework.TestCase;

/**
 * Tests the NotesClientUtil
 * Created by stefan on 24.09.15.
 */
public class NotesClientUtilTest extends TestCase {
    public void testIsHttp() {
        assertTrue(NotesClientUtil.isHttp("http://example.com"));
        assertTrue(NotesClientUtil.isHttp("http://www.example.com/"));
        assertFalse(NotesClientUtil.isHttp("https://www.example.com/"));
        assertFalse(NotesClientUtil.isHttp(null));
    }

    public void testIsValidURLTest() {
        assertTrue(NotesClientUtil.isValidURL("http://www.example.com/"));
        assertTrue(NotesClientUtil.isValidURL("https://www.example.com"));
        assertFalse(NotesClientUtil.isValidURL("htp://www.example.com/"));
        assertFalse(NotesClientUtil.isValidURL(null));
    }
}
+0 −14
Original line number Diff line number Diff line
package it.niedermann.owncloud.notes.util;

import junit.framework.TestCase;

/**
 * Tests the URLValidatorAsyncTask
 * Created by stefan on 24.09.15.
 */
public class URLValidatorAsyncTaskTest extends TestCase {
    public void testIsHttp() {
        assertTrue(URLValidatorAsyncTask.isHttp("http://www.example.com/"));
        assertFalse(URLValidatorAsyncTask.isHttp("https://www.example.com/"));
    }
}
+5 −4
Original line number Diff line number Diff line
@@ -25,8 +25,9 @@ public class Note implements Serializable {
		this.id = id;
        if(title != null)
        this.title = Html.fromHtml(and_down.markdownToHtml(title)).toString().trim();
        setTitle(title);
        setContent(content);
        this.modified = modified;
		this.content = content;
    }

	public long getId() {
@@ -38,7 +39,7 @@ public class Note implements Serializable {
	}

    public void setTitle(String title) {
        this.title = title;
        this.title = Html.fromHtml(and_down.markdownToHtml(title)).toString().trim();
    }

	@SuppressWarnings("WeakerAccess")
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ public class NotesClientUtil {
     * @return true, if the given String is only http
     */
    public static boolean isHttp(String url) {
        return url.length() > 4 && url.startsWith("http") && url.charAt(4) != 's';
        return url != null && url.length() > 4 && url.startsWith("http") && url.charAt(4) != 's';
    }

    /**