Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson committed Nov 7, 2024
1 parent 4e4c2c3 commit ca8ae6d
Showing 1 changed file with 11 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.sagebionetworks.web.unitclient.widget.entity;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
Expand Down Expand Up @@ -44,6 +47,7 @@
import org.sagebionetworks.web.client.widget.entity.*;
import org.sagebionetworks.web.client.widget.entity.menu.v3.EntityActionMenu;
import org.sagebionetworks.web.client.widget.entity.restriction.v2.RestrictionWidget;
import org.sagebionetworks.web.client.widget.projectdataavailability.ProjectDataAvaiilability;
import org.sagebionetworks.web.test.helper.AsyncMockStubber;

@RunWith(MockitoJUnitRunner.Silent.class)
Expand All @@ -55,9 +59,6 @@ public class EntityMetadataTest {
@Mock
DoiWidgetV2 mockDoiWidgetV2;

@Mock
RestrictionWidget mockRestrictionWidgetV2;

@Mock
VersionHistoryWidget mockFileHistoryWidget;

Expand All @@ -76,15 +77,15 @@ public class EntityMetadataTest {
@Mock
CookieProvider mockCookies;

@Mock
ContainerItemCountWidget mockItemCountWidget;

@Mock
PortalGinInjector mockGinInjector;

@Mock
EntityModalWidget mockEntityModalWidget;

@Mock
ProjectDataAvaiilability mockProjectDataAvaiilability;

String entityId = "syn123";
String entityName = "testEntity";
EntityMetadata widget;
Expand All @@ -102,20 +103,16 @@ public void before() {
mockDoiWidgetV2,
mockJsClient,
mockJSNI,
mockRestrictionWidgetV2,
mockItemCountWidget,
mockGinInjector,
mockEntityModalWidget
mockEntityModalWidget,
mockProjectDataAvaiilability
);
}

@Test
public void testConstruction() {
verify(mockView).setDoiWidget(any(IsWidget.class));
verify(mockView, never()).setVersionHistoryWidget(any(IsWidget.class)); // lazily created
verify(mockView).setRestrictionWidgetV2(any(IsWidget.class));
verify(mockRestrictionWidgetV2).setShowChangeLink(true);
verify(mockView).setRestrictionWidgetV2Visible(true);
}

@Test
Expand All @@ -127,7 +124,6 @@ public void testSetEntityBundleProject() {
UserEntityPermissions permissions = mock(UserEntityPermissions.class);
boolean canChangePermissions = false;
boolean canCertifiedUserEdit = true;
boolean isCurrentVersion = true;
when(permissions.getCanChangePermissions())
.thenReturn(canChangePermissions);
when(permissions.getCanCertifiedUserEdit())
Expand All @@ -141,11 +137,8 @@ public void testSetEntityBundleProject() {
bundle.setDoiAssociation(mockDoiAssociation);
widget.configure(bundle, null, mockActionMenuWidget);
verify(mockView).setDetailedMetadataVisible(true);
verify(mockView).setRestrictionPanelVisible(false);
verify(mockDoiWidgetV2).configure(mockDoiAssociation);
verify(mockRestrictionWidgetV2).configure(project, canChangePermissions);
verify(mockView, never()).setRestrictionWidgetV2Visible(false);
verify(mockItemCountWidget, never()).configure(anyString());
verify(mockProjectDataAvaiilability).setProjectId(entityId);
}

@Test
Expand All @@ -158,7 +151,6 @@ public void testSetEntityBundleProjectInAlphaMode() {
UserEntityPermissions permissions = mock(UserEntityPermissions.class);
boolean canChangePermissions = false;
boolean canCertifiedUserEdit = true;
boolean isCurrentVersion = true;
when(permissions.getCanChangePermissions())
.thenReturn(canChangePermissions);
when(permissions.getCanCertifiedUserEdit())
Expand All @@ -172,19 +164,15 @@ public void testSetEntityBundleProjectInAlphaMode() {
bundle.setDoiAssociation(mockDoiAssociation);
widget.configure(bundle, null, mockActionMenuWidget);
verify(mockView).setDetailedMetadataVisible(true);
verify(mockView).setRestrictionPanelVisible(false);
verify(mockDoiWidgetV2).configure(mockDoiAssociation);
verify(mockRestrictionWidgetV2).configure(project, canChangePermissions);
verify(mockView, never()).setRestrictionWidgetV2Visible(false);
verify(mockItemCountWidget, never()).configure(anyString());
verify(mockProjectDataAvaiilability).setProjectId(entityId);
}

@Test
public void testSetEntityBundleDockerRepo() {
UserEntityPermissions permissions = mock(UserEntityPermissions.class);
boolean canChangePermissions = true;
boolean canCertifiedUserEdit = false;
boolean isCurrentVersion = true;
when(permissions.getCanChangePermissions())
.thenReturn(canChangePermissions);
when(permissions.getCanCertifiedUserEdit())
Expand All @@ -202,7 +190,6 @@ public void testSetEntityBundleDockerRepo() {
verify(mockFileHistoryWidget, never())
.setEntityBundle(bundle, versionNumber);
verify(mockDoiWidgetV2).configure(mockDoiAssociation);
verify(mockItemCountWidget, never()).configure(anyString());
}

@Test
Expand Down Expand Up @@ -502,7 +489,6 @@ public void testSetEntityBundleFolder() {
UserEntityPermissions permissions = mock(UserEntityPermissions.class);
boolean canChangePermissions = false;
boolean canCertifiedUserEdit = true;
boolean isCurrentVersion = true;
when(permissions.getCanChangePermissions())
.thenReturn(canChangePermissions);
when(permissions.getCanCertifiedUserEdit())
Expand All @@ -515,10 +501,6 @@ public void testSetEntityBundleFolder() {
widget.configure(bundle, null, mockActionMenuWidget);
verify(mockView).setDetailedMetadataVisible(false);
verify(mockDoiWidgetV2).configure(mockDoiAssociation);
verify(mockRestrictionWidgetV2)
.configure(folderEntity, canChangePermissions);
verify(mockView, never()).setRestrictionWidgetV2Visible(false);
verify(mockItemCountWidget).configure(entityId);
}

@Test
Expand Down

0 comments on commit ca8ae6d

Please sign in to comment.