Unit test for startup metrics parsing, refactoring.

This commit is contained in:
BoykoAlex
2020-11-18 11:46:15 -05:00
parent ed68dcd47c
commit 6704262899
9 changed files with 6994 additions and 19 deletions

View File

@@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2020 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.metrics.test;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@@ -1,5 +1,37 @@
/*******************************************************************************
* Copyright (c) 2020 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.metrics.test;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.InputStreamReader;
import java.time.Duration;
import java.util.Map;
import org.junit.Test;
import org.springframework.ide.vscode.boot.java.livehover.v2.StartupMetricsModel;
import com.google.gson.Gson;
public class StartupMetricsTest {
@Test
public void testParser() throws Exception {
Gson gson = new Gson();
Map<?,?> mapContent = gson.fromJson(new InputStreamReader(getClass().getResourceAsStream("/test-files/startup.json")), Map.class);
StartupMetricsModel startupMetricsModel = StartupMetricsModel.parse(mapContent);
assertNotNull(startupMetricsModel);
assertEquals(419, startupMetricsModel.getStartupEvents().size());
assertEquals(Duration.ofNanos(10298253), startupMetricsModel.getBeanInstanciationTime("ownerController"));
}
}

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pivotal, Inc.
* Copyright (c) 2019, 2020 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,7 +23,7 @@ import org.springframework.ide.vscode.boot.java.livehover.v2.LiveMetricsModel;
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveProperties;
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMapping;
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMappingBoot1xRequestMapping;
import org.springframework.ide.vscode.boot.java.livehover.v2.StartupModel;
import org.springframework.ide.vscode.boot.java.livehover.v2.StartupMetricsModel;
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
/**
@@ -45,7 +45,7 @@ public class SpringProcessLiveDataBuilder {
private LiveConditional[] conditionals;
private LiveProperties properties;
private LiveMetricsModel metrics;
private StartupModel startup;
private StartupMetricsModel startup;
public SpringProcessLiveDataBuilder processName(String processName) {
this.processName = processName;
@@ -131,7 +131,7 @@ public class SpringProcessLiveDataBuilder {
return this;
}
public SpringProcessLiveDataBuilder liveStartup(StartupModel startup) {
public SpringProcessLiveDataBuilder liveStartup(StartupMetricsModel startup) {
this.startup = startup;
return this;
}