Unverified Commit 9fc51d87 authored by Licho's avatar Licho Committed by GitHub

feat: fix Build function error (#1644)

* feat: fix Build function error Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> * add: test Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> * Spotless Apply * refactor: junit Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> --------- Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> Co-authored-by: 's avatarleechor <leechor@users.noreply.github.com>
parent e1a5febc
...@@ -21,6 +21,8 @@ package org.dinky.executor; ...@@ -21,6 +21,8 @@ package org.dinky.executor;
import org.dinky.assertion.Asserts; import org.dinky.assertion.Asserts;
import org.apache.commons.lang3.math.NumberUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -163,9 +165,8 @@ public class ExecutorSetting { ...@@ -163,9 +165,8 @@ public class ExecutorSetting {
} }
public static ExecutorSetting build(Map<String, String> settingMap) { public static ExecutorSetting build(Map<String, String> settingMap) {
Integer checkpoint = Integer.valueOf(settingMap.get(CHECKPOINT_CONST)); Integer checkpoint = NumberUtils.createInteger(settingMap.get(CHECKPOINT_CONST));
Integer parallelism = Integer.valueOf(settingMap.get(PARALLELISM_CONST)); Integer parallelism = NumberUtils.createInteger(settingMap.get(PARALLELISM_CONST));
return build( return build(
checkpoint, checkpoint,
parallelism, parallelism,
......
/*
*
* 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
*
* http://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.dinky.executor;
import static org.dinky.executor.ExecutorSetting.CHECKPOINT_CONST;
import static org.dinky.executor.ExecutorSetting.PARALLELISM_CONST;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
/** */
class ExecutorSettingTest {
@Test
void build() {
Map<String, String> maps = new HashMap<>();
maps.put(CHECKPOINT_CONST, "123");
maps.put(PARALLELISM_CONST, "456");
ExecutorSetting es = ExecutorSetting.build(maps);
assertEquals(123, es.getCheckpoint());
assertEquals(456, es.getParallelism());
ExecutorSetting esNull = ExecutorSetting.build(Collections.emptyMap());
assertNull(esNull.getCheckpoint());
assertNull(esNull.getParallelism());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment