Refine search
private void assertIsHigherThanReportType(CrawlerDepthLimit depthLimit, Type... types) { for (Type type : types) { assertThat(depthLimit.isHigherThan(type)).as("isHigherThan(%s)", type).isTrue(); } for (Type reportType : from(REPORT_TYPES).filter(not(in(Arrays.asList(types))))) { assertThat(depthLimit.isHigherThan(reportType)).as("isHigherThan(%s)", reportType).isFalse(); } }
private void assertIsHigherThanViewsType(CrawlerDepthLimit depthLimit, Type... types) { for (Type type : types) { assertThat(depthLimit.isHigherThan(type)).as("isHigherThan(%s)", type).isTrue(); } for (Type reportType : from(VIEWS_TYPES).filter(not(in(Arrays.asList(types))))) { assertThat(depthLimit.isHigherThan(reportType)).as("isHigherThan(%s)", reportType).isFalse(); } }
private void assertIsDeeperThanReportType(CrawlerDepthLimit depthLimit, Type... types) { for (Type type : types) { assertThat(depthLimit.isDeeperThan(type)).as("isDeeperThan(%s)", type).isTrue(); } for (Type reportType : from(REPORT_TYPES).filter(not(in(Arrays.asList(types))))) { assertThat(depthLimit.isDeeperThan(reportType)).as("isDeeperThan(%s)", reportType).isFalse(); } }
private void assertIsDeeperThanViewsType(CrawlerDepthLimit depthLimit, Type... types) { for (Type type : types) { assertThat(depthLimit.isDeeperThan(type)).as("isDeeperThan(%s)", type).isTrue(); } for (Type reportType : from(VIEWS_TYPES).filter(not(in(Arrays.asList(types))))) { assertThat(depthLimit.isDeeperThan(reportType)).as("isDeeperThan(%s)", reportType).isFalse(); } }
@Test public void backslash() { assertThat(match("\\n", "\n")).as("backslash is not an escape character").isFalse(); assertThat(match("foo\\bar", "foo/bar")).as("backslash is the same as forward slash").isTrue(); }
@Test public void hasKey() throws Exception { assertThat(c.hasKey(1)).as("hasKey(1)").isTrue(); assertThat(c.hasKey(2)).as("hasKey(2)").isTrue(); assertThat(c.hasKey(3)).as("hasKey(3)").isFalse(); }
private void assertParam(String key, String value) { assertThat(servletRequestCaptor.getValue().hasParam(key)).as("Parameter '%s' hasn't been found", key).isTrue(); assertThat(servletRequestCaptor.getValue().readParam(key)).isEqualTo(value); }
@Test public void PROJECT_isHigher_than_all_report_types_but_PROJECT() { assertThat(CrawlerDepthLimit.PROJECT.isHigherThan(Type.PROJECT)).isFalse(); for (Type reportType : from(REPORT_TYPES).filter(not(equalTo(Type.PROJECT)))) { assertThat(CrawlerDepthLimit.PROJECT.isHigherThan(reportType)).as("isHigherThan(%s)", reportType).isTrue(); } }
@Test public void VIEW_isHigher_than_all_views_types_but_VIEW() { assertThat(CrawlerDepthLimit.VIEW.isHigherThan(Type.VIEW)).isFalse(); for (Type viewsType : from(VIEWS_TYPES).filter(not(equalTo(Type.VIEW)))) { assertThat(CrawlerDepthLimit.VIEW.isHigherThan(viewsType)).as("isHigherThan(%s)", viewsType).isTrue(); } }
@Test public void isEnabled_returns_true_if_worker_ordinal_is_less_than_CeConfiguration_workerCount() { int ordinal = randomWorkerCount + Math.min(-1, -random.nextInt(randomWorkerCount)); when(ceWorker.getOrdinal()).thenReturn(ordinal); assertThat(underTest.isEnabled(ceWorker)) .as("For ordinal " + ordinal + " and workerCount " + randomWorkerCount) .isTrue(); }
@Test public void PROJECT_isDeeper_than_no_views_types() { for (Type viewsType : VIEWS_TYPES) { assertThat(CrawlerDepthLimit.PROJECT.isDeeperThan(viewsType)).as("isDeeperThan(%s)", viewsType).isFalse(); } }
@Test public void FILE_isDeeper_than_no_views_types() { for (Type viewsType : VIEWS_TYPES) { assertThat(CrawlerDepthLimit.FILE.isDeeperThan(viewsType)).as("isDeeperThan(%s)", viewsType).isFalse(); } }
@Test public void isEnabled_returns_true_if_ordinal_is_invalid() { int ordinal = -1 - random.nextInt(3); when(ceWorker.getOrdinal()).thenReturn(ordinal); assertThat(underTest.isEnabled(ceWorker)) .as("For invalid ordinal " + ordinal + " and workerCount " + randomWorkerCount) .isTrue(); }
@Test public void isNonBlockingThreadInstanceOf() { Thread nonBlocking = new ReactorThreadFactory.NonBlockingThread(() -> {}, "isNonBlockingThreadInstanceOf_nonBlocking"); Thread thread = new Thread(() -> {}, "isNonBlockingThreadInstanceOf_blocking"); assertThat(Schedulers.isNonBlockingThread(nonBlocking)).as("nonBlocking").isTrue(); assertThat(Schedulers.isNonBlockingThread(thread)).as("thread").isFalse(); }
private void assertNoParam(String... keys) { Arrays.stream(keys).forEach(key -> { assertThat(servletRequestCaptor.getValue().hasParam(key)).as(key).isFalse(); assertThat(servletRequestCaptor.getValue().readParam(key)).as(key).isNull(); }); }
@Test public void testLoginSuccess() throws Exception { SecurityContextHolder.getContext().setAuthentication(this.auth); assertThat(this.module.login()) .as("Login should succeed, there is an authentication set").isTrue(); assertThat(this.module.commit()) .withFailMessage( "The authentication is not null, this should return true") .isTrue(); assertThat(this.subject.getPrincipals().contains(this.auth)) .withFailMessage("Principals should contain the authentication").isTrue(); }
@Test public void testNullAuthenticationInSecurityContextIgnored() throws Exception { this.module = new SecurityContextLoginModule(); Map<String, String> options = new HashMap<>(); options.put("ignoreMissingAuthentication", "true"); this.module.initialize(this.subject, null, null, options); SecurityContextHolder.getContext().setAuthentication(null); assertThat(this.module.login()).as("Should return false and ask to be ignored") .isFalse(); }
@Test public void redirect_post_api_properties_to_api_settings_set_when_multi_values() throws Exception { when(request.getRequestURI()).thenReturn("/api/properties/my.property"); when(request.getParameter("value")).thenReturn("value1,value2,value3"); when(request.getMethod()).thenReturn("POST"); underTest.doFilter(request, response, chain); assertRedirection("api/settings/set", "POST"); assertParam("key", "my.property"); assertNoParam("value"); assertThat(servletRequestCaptor.getValue().hasParam("values")).as("Parameter '%s' hasn't been found", "values").isTrue(); assertThat(servletRequestCaptor.getValue().readMultiParam("values")).containsOnly("value1", "value2", "value3"); }
@Test public void isInNonBlockingThreadFalse() { assertThat(Thread.currentThread()).isNotInstanceOf(NonBlocking.class); assertThat(Schedulers.isInNonBlockingThread()).as("isInNonBlockingThread").isFalse(); }
@Test public void can_move_to_STOPPING_from_STARTING_STARTED_only() { for (Lifecycle.State state : Lifecycle.State.values()) { TestLifeCycleListener listener = new TestLifeCycleListener(); boolean tryToMoveTo = newLifeCycle(state, listener).tryToMoveTo(STOPPING); if (state == STARTING || state == STARTED) { assertThat(tryToMoveTo).as("from state " + state).isTrue(); assertThat(listener.states).containsOnly(STOPPING); } else { assertThat(tryToMoveTo).as("from state " + state).isFalse(); assertThat(listener.states).isEmpty(); } } }