APISonar


io.spring.initializr.actuate.stat.MainControllerStatsIntegrationTests.StatsMockController.Content.json

> io > spring > initializr > actuate > stat > MainControllerStatsIntegrationTests > StatsMockController > Content > json
io APIs spring APIs initializr APIs actuate APIs stat APIs MainControllerStatsIntegrationTests APIs StatsMockController APIs Content APIs json APIs

Example 1
void requestIpv4IsNotSetWhenHeaderHasGarbage() throws Exception {
		RequestEntity<?> request = RequestEntity.get(new URI(createUrl("/starter.zip")))
				.header("x-forwarded-for", "foo-bar").build();
		getRestTemplate().exchange(request, String.class);
		assertThat(this.statsMockController.stats).as("No stat got generated").hasSize(1);
		StatsMockController.Content content = this.statsMockController.stats.get(0);

		JsonNode json = parseJson(content.json);
		assertThat(json.has("requestIpv4")).as("requestIpv4 property should not be set if value is not a valid IPv4")
				.isFalse();
	}
Example 2
void simpleProject() {
		downloadArchive("/starter.zip?groupId=com.foo&artifactId=bar&dependencies=web");
		assertThat(this.statsMockController.stats).as("No stat got generated").hasSize(1);
		StatsMockController.Content content = this.statsMockController.stats.get(0);

		JsonNode json = parseJson(content.json);
		assertThat(json.get("groupId").textValue()).isEqualTo("com.foo");
		assertThat(json.get("artifactId").textValue()).isEqualTo("bar");
		JsonNode list = json.get("dependencies").get("values");
		assertThat(list).hasSize(1);
		assertThat(list.get(0).textValue()).isEqualTo("web");
	}