Skip to content

Commit

Permalink
Add some ut cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
xianrenzw committed Feb 11, 2025
1 parent ff6142a commit 8d8cf39
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,48 @@
*/
package org.apache.bigtop.manager.stack.infra.v1_0_0.grafana;

import org.apache.bigtop.manager.stack.core.spi.param.Params;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class GrafanaServerScriptTest {

private final GrafanaServerScript grafanaServerScript = new GrafanaServerScript();

@Test
public void testGetComponentName() {
GrafanaServerScript grafanaServerScript = new GrafanaServerScript();
assertEquals("grafana_server", grafanaServerScript.getComponentName());
}

@Test
public void testAddParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> grafanaServerScript.add(params));
}

@Test
public void testConfigureParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> grafanaServerScript.configure(params));
}

@Test
public void testStartParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> grafanaServerScript.start(params));
}

@Test
public void testStopParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> grafanaServerScript.stop(params));
}

@Test
public void testStatusParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> grafanaServerScript.status(params));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,48 @@
*/
package org.apache.bigtop.manager.stack.infra.v1_0_0.mysql;

import org.apache.bigtop.manager.stack.core.spi.param.Params;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

class MySQLServerScriptTest {

private final MySQLServerScript mysqlServerScript = new MySQLServerScript();

@Test
void testGetComponentName() {
MySQLServerScript mysqlServerScript = new MySQLServerScript();
assertEquals("mysql_server", mysqlServerScript.getComponentName());
}

@Test
public void testAddParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> mysqlServerScript.add(params));
}

@Test
public void testConfigureParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> mysqlServerScript.configure(params));
}

@Test
public void testStartParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> mysqlServerScript.start(params));
}

@Test
public void testStopParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> mysqlServerScript.stop(params));
}

@Test
public void testStatusParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> mysqlServerScript.status(params));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,48 @@
*/
package org.apache.bigtop.manager.stack.infra.v1_0_0.prometheus;

import org.apache.bigtop.manager.stack.core.spi.param.Params;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class PrometheusServerScriptTest {

private final PrometheusServerScript prometheusServerScript = new PrometheusServerScript();

@Test
public void testGetComponentName() {
PrometheusServerScript script = new PrometheusServerScript();
assertEquals("prometheus_server", script.getComponentName());
assertEquals("prometheus_server", prometheusServerScript.getComponentName());
}

@Test
public void testAddParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> prometheusServerScript.add(params));
}

@Test
public void testConfigureParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> prometheusServerScript.configure(params));
}

@Test
public void testStartParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> prometheusServerScript.start(params));
}

@Test
public void testStopParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> prometheusServerScript.stop(params));
}

@Test
public void testStatusParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> prometheusServerScript.status(params));
}
}

0 comments on commit 8d8cf39

Please sign in to comment.