Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] engine version support hyphen #4246

Merged
merged 6 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,19 @@ public void setVersion(String version) {
public Boolean isEmpty() {
return StringUtils.isBlank(getEngineType()) || StringUtils.isBlank(getVersion());
}

@Override
protected void setStringValue(String stringValue) {
String version;
String engineType = stringValue.split("-")[0];

if (engineType.equals("*")) {
version = stringValue.replaceFirst("[" + engineType + "]-", "");
} else {
version = stringValue.replaceFirst(engineType + "-", "");
}

setEngineType(engineType);
setVersion(version);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.apache.linkis.manager.label.entity.engine;

import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactory;
import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext;

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

/** EngineTypeLabel Tester */
public class EngineTypeLabelTest {

@Test
public void testSetStringValue() {
String engineType = "hive";
String version = "1.1.0-cdh5.12.0";

String engineType1 = "*";
String version1 = "*";

LabelBuilderFactory labelBuilderFactory = LabelBuilderFactoryContext.getLabelBuilderFactory();
EngineTypeLabel engineTypeLabel = labelBuilderFactory.createLabel(EngineTypeLabel.class);
engineTypeLabel.setStringValue(engineType + "-" + version);
Assertions.assertEquals(engineTypeLabel.getEngineType(), engineType);
Assertions.assertEquals(engineTypeLabel.getVersion(), version);

engineTypeLabel.setStringValue(engineType1 + "-" + version1);
Assertions.assertEquals(engineTypeLabel.getEngineType(), engineType1);
Assertions.assertEquals(engineTypeLabel.getVersion(), version1);
}
}