Skip to content

Commit c980e44

Browse files
committed
mock permalink for test
1 parent e2cdc89 commit c980e44

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/test/java/org/commonwl/view/researchobject/ROBundleServiceTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,15 @@ public void setUp() throws Exception {
119119
when(lobSTRdraft3.getID()).thenReturn("testID");
120120
when(lobSTRdraft3.getRetrievedFrom()).thenReturn(lobSTRdraft3Details);
121121
when(lobSTRdraft3.getLastCommit()).thenReturn("933bf2a1a1cce32d88f88f136275535da9df0954");
122-
when(lobSTRdraft3.getIdentifier()).thenReturn("https://w3id.org/cwl/view/git/" +
123-
"933bf2a1a1cce32d88f88f136275535da9df0954/workflows/lobSTR/lobSTR-workflow.cwl");
122+
final String permalink = "https://w3id.org/cwl/view/git/" +
123+
"933bf2a1a1cce32d88f88f136275535da9df0954/workflows/lobSTR/lobSTR-workflow.cwl";
124+
when(lobSTRdraft3.getIdentifier()).thenReturn(permalink);
125+
when(lobSTRdraft3.getPermalink()).thenReturn(permalink);
124126
when(lobSTRdraft3.getPermalink(any())).thenAnswer(new Answer<String>() {
125127
@Override
126128
public String answer(InvocationOnMock invocation) throws Throwable {
127129
Object[] args = invocation.getArguments();
128-
return "https://w3id.org/cwl/view/git/933bf2a1a1cce32d88f88f136275535da9df0954/" +
129-
"workflows/lobSTR/lobSTR-workflow.cwl?format=" + args[0];
130+
return permalink + "?format=" + args[0];
130131
}
131132
});
132133
}

src/test/java/org/commonwl/view/workflow/WorkflowPermalinkControllerTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import java.io.File;
3636
import java.io.FileInputStream;
37+
import java.util.Optional;
3738

3839
import static org.mockito.Matchers.*;
3940
import static org.mockito.Mockito.when;
@@ -61,9 +62,15 @@ public void setUp() throws Exception {
6162
.thenReturn(new GitDetails("https://github.com/MarkRobbo/workflows.git",
6263
"master", "path/to/workflow.cwl"));
6364

65+
66+
6467
WorkflowService mockWorkflowService = Mockito.mock(WorkflowService.class);
65-
when(mockWorkflowService.findByCommitAndPath(anyString(), anyString()))
66-
.thenReturn(mockWorkflow);
68+
when(mockWorkflowService.findByCommitAndPath(anyString(), anyString(), anyObject()))
69+
.thenReturn(mockWorkflow);
70+
71+
when(mockWorkflowService.findRawBaseForCommit(anyString())).thenReturn(
72+
Optional.of("https://raw.githubusercontent.com/MarkRobbo/workflows/commitidhere/"));
73+
6774
when(mockWorkflowService.getWorkflowGraph(eq("svg"), anyObject())).thenReturn(svg);
6875
when(mockWorkflowService.getWorkflowGraph(eq("png"), anyObject())).thenReturn(png);
6976
when(mockWorkflowService.getWorkflowGraph(eq("xdot"), anyObject())).thenReturn(dot);

0 commit comments

Comments
 (0)