Skip to content

Commit 180d597

Browse files
committed
Mirrored rspec test for StringSetting into JUnit
1 parent 61540ee commit 180d597

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

logstash-core/spec/logstash/settings/string_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
require "spec_helper"
1919
require "logstash/settings"
2020

21+
# Mirrored in java class org.logstash.settings.StringSettingTest
2122
describe LogStash::Setting::StringSetting do
2223
let(:possible_values) { ["a", "b", "c"] }
2324
subject { described_class.new("mytext", possible_values.first, true, possible_values) }

logstash-core/src/test/java/org/logstash/settings/BooleanTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
120
package org.logstash.settings;
221

322
import org.junit.Assert;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.logstash.settings;
20+
21+
import org.junit.Before;
22+
import org.junit.Test;
23+
24+
import java.util.List;
25+
26+
import static org.junit.Assert.assertEquals;
27+
28+
// Mirrored from logstash-core/spec/logstash/settings/string_spec.rb
29+
public class StringSettingTest {
30+
31+
private static final List<String> POSSIBLE_VALUES = List.of("a", "b", "c");
32+
private StringSetting sut;
33+
34+
@Before
35+
public void setUp() throws Exception {
36+
sut = new StringSetting("mytext", POSSIBLE_VALUES.iterator().next(), true, POSSIBLE_VALUES);
37+
}
38+
39+
@Test(expected = IllegalArgumentException.class)
40+
public void whenSetValueNotPresentInPossibleValuesThenThrowAnError() {
41+
sut.set("d");
42+
}
43+
44+
@Test
45+
public void whenSetValuePresentInPossibleValuesThenSetValue() {
46+
sut.set("a");
47+
48+
assertEquals("a", sut.value());
49+
}
50+
}

0 commit comments

Comments
 (0)