RunnerUtilImpl implements RunnerUtil { @Override public boolean hasRunPermission() { CurrentProject currentProject = appContext.getCurrentProject(); return currentProject != null && currentProject.getProjectDescription().getPermissions().contains("run"); } @Inject  RunnerUtilImpl(DialogFactory dialogFactory,
                          RunnerLocalizationConstant locale,
                          Provider<RunnerManagerPresenter> presenter,
                          ConsoleContainer consoleContainer,
                          NotificationManager notificationManager,
                          AppContext appContext); @Override boolean isRunnerMemoryCorrect(@Min(value=0) int totalMemory, @Min(value=0) int usedMemory, @Min(value=0) int availableMemory); @Override void showWarning(@NotNull String message); @Override void showError(@NotNull Runner runner, @NotNull String message, @Nullable Throwable exception); @Override void showError(@NotNull Runner runner,
                          @NotNull String message,
                          @Nullable Throwable exception,
                          @NotNull Notification notification); @Override boolean hasRunPermission();  }
@Test public void userShouldBeHasPermissionForRunProject() { List<String> permissions = Arrays.asList("run"); when(projectDescriptor.getPermissions()).thenReturn(permissions); assertThat(util.hasRunPermission(), is(true)); }
@Test public void userShouldNotHasPermissionForRunProjectBecauseProjectIsNull() { when(applicationContext.getCurrentProject()).thenReturn(null); assertThat(util.hasRunPermission(), is(false)); }
@Test public void userShouldNotHasPermissionForRunProject() { List<String> permissions = Arrays.asList(); when(projectDescriptor.getPermissions()).thenReturn(permissions); assertThat(util.hasRunPermission(), is(false)); }