Skip to content

Commit 5dd3878

Browse files
Merge pull request #208 from rosette-api/tej-1997-add-event-negation-options
Tej 1997 add event negation options
2 parents 468fd30 + ffd22d6 commit 5dd3878

File tree

5 files changed

+135
-6
lines changed

5 files changed

+135
-6
lines changed

CI.Jenkinsfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ node ("docker-light") {
2525
/opt/maven-basis/bin/mvn --batch-mode clean install sonar:sonar $mySonarOpts\""
2626
}
2727
}
28-
slack(true)
28+
postToTeams(true)
2929
} catch (e) {
3030
currentBuild.result = "FAILED"
31-
slack(false)
31+
postToTeams(false)
3232
throw e
3333
}
3434
}
3535

36-
def slack(boolean success) {
36+
def postToTeams(boolean success) {
37+
def webhookUrl = "${env.TEAMS_PNC_JENKINS_WEBHOOK_URL}"
3738
def color = success ? "#00FF00" : "#FF0000"
3839
def status = success ? "SUCCESSFUL" : "FAILED"
39-
def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
40-
slackSend(color: color, channel: "#p-n-c_jenkins", message: message)
40+
def message = "*" + status + ":* '${env.JOB_NAME}' - [${env.BUILD_NUMBER}] - ${env.BUILD_URL}"
41+
office365ConnectorSend(webhookUrl: webhookUrl, color: color, message: message, status: status)
4142
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2023 Basis Technology Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.basistech.rosette.apimodel;
18+
19+
import java.util.Arrays;
20+
import java.util.Map;
21+
import java.util.function.Function;
22+
import java.util.stream.Collectors;
23+
24+
public enum EventsNegationOption {
25+
IGNORE("Ignore"),
26+
BOTH("Both"),
27+
ONLY_POSITIVE("Only positive"),
28+
ONLY_NEGATIVE("Only negative");
29+
30+
private static final Map<String, EventsNegationOption> STRING_KEYS;
31+
32+
static {
33+
STRING_KEYS = Arrays.stream(EventsNegationOption.values())
34+
.collect(Collectors.toMap(
35+
value -> value.toString().toLowerCase(),
36+
Function.identity()
37+
));
38+
}
39+
40+
private final String label;
41+
42+
EventsNegationOption(String label) {
43+
this.label = label;
44+
}
45+
46+
public static EventsNegationOption forValue(String value) {
47+
return STRING_KEYS.get(value.toLowerCase());
48+
}
49+
50+
@Override
51+
public String toString() {
52+
return label;
53+
}
54+
}

model/src/main/java/com/basistech/rosette/apimodel/EventsOptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ public class EventsOptions extends Options {
3434
/**
3535
* Default options
3636
*/
37-
public static final EventsOptions DEFAULT = EventsOptions.builder().build();
37+
public static final EventsOptions DEFAULT = EventsOptions.builder().negation(EventsNegationOption.IGNORE).build();
3838

3939
/**
4040
* workspaceId to use.
4141
*/
4242
String workspaceId;
4343

4444
EnumMap<LanguageCode, List<String>> plan;
45+
46+
EventsNegationOption negation;
4547
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2023 Basis Technology Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.basistech.rosette.apimodel;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNull;
23+
24+
class EventsNegationOptionTest {
25+
26+
@Test
27+
void forValueSuccess() {
28+
assertEquals(EventsNegationOption.IGNORE, EventsNegationOption.forValue("ignore"));
29+
assertEquals(EventsNegationOption.BOTH, EventsNegationOption.forValue("BOTH"));
30+
assertEquals(EventsNegationOption.ONLY_POSITIVE, EventsNegationOption.forValue("Only Positive"));
31+
assertEquals(EventsNegationOption.ONLY_NEGATIVE, EventsNegationOption.forValue("OnLy NeGaTiVe"));
32+
}
33+
34+
@Test
35+
void forValueFailure() {
36+
assertNull(EventsNegationOption.forValue("dummy"));
37+
}
38+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2023 Basis Technology Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.basistech.rosette.apimodel;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static com.basistech.rosette.apimodel.EventsOptions.DEFAULT;
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import static org.junit.jupiter.api.Assertions.assertNotNull;
24+
25+
class EventsOptionsTest {
26+
27+
@Test
28+
void builderDefaults() {
29+
var eventsOptions = DEFAULT;
30+
assertNotNull(eventsOptions);
31+
32+
assertEquals(EventsNegationOption.IGNORE, eventsOptions.getNegation());
33+
}
34+
}

0 commit comments

Comments
 (0)