From 61cd35f76bdeeb82e771ff53931bcaf07f44a942 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Sat, 22 Sep 2012 10:37:52 -0700 Subject: Add unit tests of CommitStatus model Change-Id: I2d0e0244e5a9767c7c89cd25af3ce083a3bcb463 --- .../egit/github/core/tests/AllHeadlessTests.java | 1 + .../egit/github/core/tests/CommitStatusTest.java | 62 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatusTest.java diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java index 927d2841..9808ae6c 100644 --- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java @@ -29,6 +29,7 @@ import org.junit.runners.Suite.SuiteClasses; CommitFileTest.class, // CommitServiceTest.class, // CommitStatsTest.class, // + CommitStatusTest.class, // CommitTest.class, // CommitUserTest.class, // ContributorTest.class, // diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatusTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatusTest.java new file mode 100644 index 00000000..0abb0275 --- /dev/null +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/CommitStatusTest.java @@ -0,0 +1,62 @@ +/****************************************************************************** + * Copyright (c) 2012 GitHub Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Kevin Sawicki (GitHub Inc.) - initial API and implementation + *****************************************************************************/ +package org.eclipse.egit.github.core.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Date; + +import org.eclipse.egit.github.core.CommitStatus; +import org.eclipse.egit.github.core.User; +import org.junit.Test; + +/** + * Unit tests of {@link CommitStatus} + */ +public class CommitStatusTest { + + /** + * Test default state of commit status + */ + @Test + public void defaultState() { + CommitStatus status = new CommitStatus(); + assertNull(status.getCreatedAt()); + assertNull(status.getCreator()); + assertNull(status.getDescription()); + assertEquals(0, status.getId()); + assertNull(status.getState()); + assertNull(status.getTargetUrl()); + assertNull(status.getUpdatedAt()); + assertNull(status.getUrl()); + } + + /** + * Test updating commit status fields + */ + @Test + public void updateFields() { + CommitStatus status = new CommitStatus(); + assertEquals(new Date(1234), status.setCreatedAt(new Date(1234)) + .getCreatedAt()); + User creator = new User().setId(1); + assertEquals(creator, status.setCreator(creator).getCreator()); + assertEquals("desc", status.setDescription("desc").getDescription()); + assertEquals(40, status.setId(40).getId()); + assertEquals("state", status.setState("state").getState()); + assertEquals("targetUrl", status.setTargetUrl("targetUrl") + .getTargetUrl()); + assertEquals(new Date(5678), status.setUpdatedAt(new Date(5678)) + .getUpdatedAt()); + assertEquals("url", status.setUrl("url").getUrl()); + } +} -- cgit v1.2.3