public HttpResponseAssert hasStatusCode(int... httpStatus) { int statusCode = actual.getStatusLine().getStatusCode(); assertThat(statusCode) .describedAs(logMessage + "\n" + descriptionText()) .isIn(Arrays.stream(httpStatus).boxed().collect(Collectors.toList())); return this; }
public DisplayAssert isPortrait() { isNotNull(); int actualOrientation = actual.getOrientation(); //noinspection ResourceType assertThat(actualOrientation) // .overridingErrorMessage("Expected orientation <%s> or <%s>, but was <%s>", orientationToString(ROTATION_0), orientationToString(ROTATION_180), orientationToString(actualOrientation)) // .isIn(ROTATION_0, ROTATION_180); return this; }
public DisplayAssert isLandscape() { isNotNull(); int actualOrientation = actual.getOrientation(); //noinspection ResourceType assertThat(actualOrientation) // .overridingErrorMessage("Expected orientation <%s> or <%s>, but was <%s>", orientationToString(ROTATION_270), orientationToString(ROTATION_90), orientationToString(actualOrientation)) // .isIn(ROTATION_270, ROTATION_90); return this; }
@Then("^the user should be authorized$") public void httpStatusDifferentFromUnauthorized() { assertThat(response.getStatusLine().getStatusCode()).isIn(200, 404); }
public DisplayAssert isPortrait() { isNotNull(); int actualOrientation = actual.getOrientation(); //noinspection ResourceType assertThat(actualOrientation) // .overridingErrorMessage("Expected orientation <%s> or <%s>, but was <%s>", orientationToString(ROTATION_0), orientationToString(ROTATION_180), orientationToString(actualOrientation)) // .isIn(ROTATION_0, ROTATION_180); return this; }
public DisplayAssert isLandscape() { isNotNull(); int actualOrientation = actual.getOrientation(); //noinspection ResourceType assertThat(actualOrientation) // .overridingErrorMessage("Expected orientation <%s> or <%s>, but was <%s>", orientationToString(ROTATION_270), orientationToString(ROTATION_90), orientationToString(actualOrientation)) // .isIn(ROTATION_270, ROTATION_90); return this; }
@Test public void shouldHaveHealthCheck() { final ResponseEntity<String> response = this.restTemplate.getForEntity("/actuator/health", String.class); assertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON_UTF8); assertThat(response.getStatusCodeValue()).isIn(200, 503); }
@Test public void shouldHaveHealthCheck() { final ResponseEntity<String> response = this.restTemplate.getForEntity("/actuator/health", String.class); assertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON_UTF8); assertThat(response.getStatusCodeValue()).isIn(200, 503); }
@Example void choosesOneOfManyAccordingToFrequency(@ForAll Random random) { Arbitrary<Integer> one = Arbitraries.of(1); Arbitrary<Integer> two = Arbitraries.of(2); Arbitrary<Integer> frequencyOfArbitrary = Arbitraries.frequencyOf(Tuple.of(10, one), Tuple.of(1, two)); ArbitraryTestHelper.assertAllGenerated(frequencyOfArbitrary.generator(1000), value -> { assertThat(value).isIn(1, 2); }); RandomGenerator<Integer> generator = frequencyOfArbitrary.generator(1000); ArbitraryTestHelper.assertAtLeastOneGeneratedOf(generator, 1, 2); List<Integer> elements = generator.stream(random).map(Shrinkable::value).limit(100).collect(Collectors.toList()); int countOnes = Collections.frequency(elements, 1); int countTwos = Collections.frequency(elements, 2); assertThat(countOnes).isGreaterThan(countTwos * 2); }
@Example void choosesOneOfManyArbitraries() { Arbitrary<Integer> one = Arbitraries.of(1); Arbitrary<Integer> two = Arbitraries.of(2); Arbitrary<Integer> threeToFive = Arbitraries.of(3, 4, 5); Arbitrary<Integer> oneOfArbitrary = Arbitraries.oneOf(one, two, threeToFive); ArbitraryTestHelper.assertAllGenerated(oneOfArbitrary.generator(1000), value -> { assertThat(value).isIn(1, 2, 3, 4, 5); }); RandomGenerator<Integer> generator = oneOfArbitrary.generator(1000); ArbitraryTestHelper.assertAtLeastOneGeneratedOf(generator, 1, 2, 3, 4, 5); }
@Test(groups = { "integration", "live" }) public void testCopyIfModifiedSinceNegative() throws Exception { BlobStore blobStore = view.getBlobStore(); String fromName = "source"; String toName = "to"; ByteSource payload = TestUtils.randomByteSource().slice(0, 1024); Blob blob = blobStore .blobBuilder(fromName) .payload(payload) .contentLength(payload.size()) .build(); String fromContainer = getContainerName(); String toContainer = getContainerName(); try { blobStore.putBlob(fromContainer, blob); // TODO: some problem with S3 and times in the future? Date after = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1)); try { blobStore.copyBlob(fromContainer, fromName, toContainer, toName, CopyOptions.builder().ifModifiedSince(after).build()); Fail.failBecauseExceptionWasNotThrown(HttpResponseException.class); } catch (HttpResponseException hre) { // most object stores return 412 but swift returns 304 assertThat(hre.getResponse().getStatusCode()).isIn(304, 412); } } finally { returnContainer(toContainer); returnContainer(fromContainer); } }
assertThat(code3).isIn(OK.getStatusCode(), CREATED.getStatusCode()); // 200 or 201 if upload succeeded