Skip to content

Commit

Permalink
BIGTOP-4349: Add some unit tests for stack extra module (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
xianrenzw authored Feb 13, 2025
1 parent 788c3b4 commit 7a2ba19
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.bigtop.manager.stack.extra.v1_0_0.seatunnel;

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 SeaTunnelClientScriptTest {

private final SeaTunnelClientScript clientScript = new SeaTunnelClientScript();

@Test
public void testGetComponentName() {
assertEquals("seatunnel_client", clientScript.getComponentName());
}

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

@Test
public void testConfigureParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> clientScript.configure(params));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.bigtop.manager.stack.extra.v1_0_0.seatunnel;

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 SeaTunnelMasterScriptTest {

private final SeaTunnelMasterScript seaTunnelMasterScript = new SeaTunnelMasterScript();

@Test
public void testGetComponentName() {
assertEquals("seatunnel_master", seaTunnelMasterScript.getComponentName());
}

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

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

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

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

@Test
public void testStatusParamsNull() {
Params params = null;
assertThrows(NullPointerException.class, () -> seaTunnelMasterScript.status(params));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.bigtop.manager.stack.extra.v1_0_0.seatunnel;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class SeaTunnelParamsTest {

private SeaTunnelParams seaTunnelParams;

@BeforeEach
public void setUp() {
seaTunnelParams = mock(SeaTunnelParams.class);
when(seaTunnelParams.stackHome()).thenReturn("/stack");
when(seaTunnelParams.getServiceName()).thenCallRealMethod();
when(seaTunnelParams.serviceHome()).thenCallRealMethod();
when(seaTunnelParams.sparkHome()).thenCallRealMethod();
when(seaTunnelParams.flinkHome()).thenCallRealMethod();
when(seaTunnelParams.confDir()).thenCallRealMethod();
}

@Test
public void testServiceHome() {
assertEquals("/stack/seatunnel", seaTunnelParams.serviceHome());
}

@Test
public void testConfDir() {
assertEquals("/stack/seatunnel/config", seaTunnelParams.confDir());
}

@Test
public void testSparkHome() {
assertEquals("/stack/spark", seaTunnelParams.sparkHome());
}

@Test
public void testFlinkHome() {
assertEquals("/stack/flink", seaTunnelParams.flinkHome());
}

@Test
public void testGetServiceName() {
assertEquals("seatunnel", seaTunnelParams.getServiceName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.bigtop.manager.stack.extra.v1_0_0.seatunnel;

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 SeaTunnelWorkerScriptTest {

private final SeaTunnelWorkerScript seaTunnelWorkerScript = new SeaTunnelWorkerScript();

@Test
public void testGetComponentName() {
assertEquals("seatunnel_worker", seaTunnelWorkerScript.getComponentName());
}

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

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

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

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

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

0 comments on commit 7a2ba19

Please sign in to comment.