Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-08-01 20:30:35 -0400
committerRoberto E. Escobar2014-09-29 18:55:03 -0400
commit1e6dc21b6ce89e72448d52ba35b47a08d2f67660 (patch)
treeea9d70bfb917f23263d526c2eb3239b4e1d7a143 /plugins/org.eclipse.osee.account.rest.test
parentad47a2aa52b0ef52d11a325dd1a859ca515b8c29 (diff)
downloadorg.eclipse.osee-1e6dc21b6ce89e72448d52ba35b47a08d2f67660.tar.gz
org.eclipse.osee-1e6dc21b6ce89e72448d52ba35b47a08d2f67660.tar.xz
org.eclipse.osee-1e6dc21b6ce89e72448d52ba35b47a08d2f67660.zip
feature: Convert Unsubscribe to use JAX-RS MVC
Diffstat (limited to 'plugins/org.eclipse.osee.account.rest.test')
-rw-r--r--plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java40
1 files changed, 29 insertions, 11 deletions
diff --git a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java
index 1f6f931e02..c2a111bf33 100644
--- a/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java
+++ b/plugins/org.eclipse.osee.account.rest.test/src/org/eclipse/osee/account/rest/internal/UnsubscribeResourceTest.java
@@ -10,6 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.account.rest.internal;
+import static org.eclipse.osee.account.rest.internal.UnsubscribeResource.ACCOUNT_DISPLAY_NAME_TAG;
+import static org.eclipse.osee.account.rest.internal.UnsubscribeResource.SUBSCRIPTION_NAME_TAG;
+import static org.eclipse.osee.account.rest.internal.UnsubscribeResource.UNSUBSCRIBE_NO_SUBSCRIPTION_TEMPLATE;
+import static org.eclipse.osee.account.rest.internal.UnsubscribeResource.UNSUBSCRIBE_TEMPLATE;
+import static org.eclipse.osee.account.rest.internal.UnsubscribeResource.UNSUBSCRIBE_URL;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -18,7 +24,7 @@ import java.net.URI;
import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.account.admin.Subscription;
import org.eclipse.osee.account.admin.SubscriptionAdmin;
-import org.eclipse.osee.account.rest.internal.UnsubscribeResource.UnsubscribePageWriter;
+import org.eclipse.osee.framework.jdk.core.type.ViewModel;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -41,7 +47,6 @@ public class UnsubscribeResourceTest {
//@formatter:off
@Mock private SubscriptionAdmin manager;
@Mock private Subscription subscription;
- @Mock private UnsubscribePageWriter writer;
//@formatter:on
private UnsubscribeResource resource;
@@ -50,7 +55,7 @@ public class UnsubscribeResourceTest {
public void setUp() {
initMocks(this);
- resource = new UnsubscribeResource(manager, writer);
+ resource = new UnsubscribeResource(manager);
when(subscription.getGuid()).thenReturn(GROUP_UUID);
when(subscription.getGroupId()).thenReturn(GROUP_ID);
@@ -67,12 +72,16 @@ public class UnsubscribeResourceTest {
URI expected = UriBuilder.fromPath(SUBSCRIPTION_UUID).path("confirm").build();
- resource.getUnsubscribePage(SUBSCRIPTION_UUID);
+ ViewModel actual = resource.getUnsubscribePage(SUBSCRIPTION_UUID);
verify(manager).getSubscription(SUBSCRIPTION_UUID);
verify(subscription).isActive();
verify(subscription).getGuid();
- verify(writer).newUnsubscribePage(expected, GROUP_NAME, ACCOUNT_NAME);
+
+ assertEquals(UNSUBSCRIBE_TEMPLATE, actual.getViewId());
+ assertEquals(GROUP_NAME, actual.asMap().get(SUBSCRIPTION_NAME_TAG));
+ assertEquals(ACCOUNT_NAME, actual.asMap().get(ACCOUNT_DISPLAY_NAME_TAG));
+ assertEquals(expected, actual.asMap().get(UNSUBSCRIBE_URL));
}
@Test
@@ -80,12 +89,15 @@ public class UnsubscribeResourceTest {
when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription);
when(subscription.isActive()).thenReturn(false);
- resource.getUnsubscribePage(SUBSCRIPTION_UUID);
+ ViewModel actual = resource.getUnsubscribePage(SUBSCRIPTION_UUID);
verify(manager).getSubscription(SUBSCRIPTION_UUID);
verify(subscription).isActive();
verify(subscription, times(0)).getGuid();
- verify(writer).newUnsubscribeNoSubscriptionFoundPage(GROUP_NAME, ACCOUNT_NAME);
+
+ assertEquals(UNSUBSCRIBE_NO_SUBSCRIPTION_TEMPLATE, actual.getViewId());
+ assertEquals(GROUP_NAME, actual.asMap().get(SUBSCRIPTION_NAME_TAG));
+ assertEquals(ACCOUNT_NAME, actual.asMap().get(ACCOUNT_DISPLAY_NAME_TAG));
}
@Test
@@ -93,11 +105,14 @@ public class UnsubscribeResourceTest {
when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription);
when(manager.setSubscriptionActive(subscription, false)).thenReturn(true);
- resource.processUnsubscribePage(SUBSCRIPTION_UUID);
+ ViewModel actual = resource.processUnsubscribePage(SUBSCRIPTION_UUID);
verify(manager).getSubscription(SUBSCRIPTION_UUID);
verify(manager).setSubscriptionActive(subscription, false);
- verify(writer).newUnsubscribeSuccessPage(GROUP_NAME, ACCOUNT_NAME);
+
+ assertEquals(UnsubscribeResource.UNSUBSCRIBE_SUCCESS_TEMPLATE, actual.getViewId());
+ assertEquals(GROUP_NAME, actual.asMap().get(SUBSCRIPTION_NAME_TAG));
+ assertEquals(ACCOUNT_NAME, actual.asMap().get(ACCOUNT_DISPLAY_NAME_TAG));
}
@Test
@@ -105,11 +120,14 @@ public class UnsubscribeResourceTest {
when(manager.getSubscription(SUBSCRIPTION_UUID)).thenReturn(subscription);
when(manager.setSubscriptionActive(subscription, false)).thenReturn(false);
- resource.processUnsubscribePage(SUBSCRIPTION_UUID);
+ ViewModel actual = resource.processUnsubscribePage(SUBSCRIPTION_UUID);
verify(manager).getSubscription(SUBSCRIPTION_UUID);
verify(manager).setSubscriptionActive(subscription, false);
- verify(writer).newUnsubscribeNoSubscriptionFoundPage(GROUP_NAME, ACCOUNT_NAME);
+
+ assertEquals(UNSUBSCRIBE_NO_SUBSCRIPTION_TEMPLATE, actual.getViewId());
+ assertEquals(GROUP_NAME, actual.asMap().get(SUBSCRIPTION_NAME_TAG));
+ assertEquals(ACCOUNT_NAME, actual.asMap().get(ACCOUNT_DISPLAY_NAME_TAG));
}
}

Back to the top