Skip to content

Commit cd7a82a

Browse files
committed
Merge branch '7.3'
2 parents 2d077aa + d8ff3e5 commit cd7a82a

File tree

21 files changed

+508
-75
lines changed

21 files changed

+508
-75
lines changed

stroom-analytics/stroom-analytics-impl/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ dependencies {
5555
testImplementation libs.assertj_core
5656
testImplementation libs.guice_extension
5757
testImplementation libs.junit_jupiter_api
58+
testImplementation libs.mockito_core
59+
testImplementation libs.mockito_junit_jupiter
5860

5961
// The following logging libs are needed when running junits outside dropwizard
6062
testRuntimeOnly libs.jakarta_activation

stroom-analytics/stroom-analytics-impl/src/main/java/stroom/analytics/impl/SmtpConfig.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
@JsonPropertyOrder(alphabetic = true)
3939
public class SmtpConfig extends AbstractConfig implements IsStroomConfig {
4040

41+
public static final String DEFAULT_TRANSPORT = "plain";
42+
4143
@NotNull
4244
@JsonProperty("host")
4345
@JsonPropertyDescription("The fully qualified hostname of the SMTP server.")
@@ -66,7 +68,7 @@ public class SmtpConfig extends AbstractConfig implements IsStroomConfig {
6668
public SmtpConfig() {
6769
host = "localhost";
6870
port = 2525;
69-
transport = "plain";
71+
transport = DEFAULT_TRANSPORT;
7072
password = null;
7173
username = null;
7274
}
@@ -85,6 +87,11 @@ public SmtpConfig(@JsonProperty("host") final String host,
8587
this.password = password;
8688
}
8789

90+
public static SmtpConfig unauthenticated(final String host,
91+
final int port) {
92+
return new SmtpConfig(host, port, DEFAULT_TRANSPORT, null, null);
93+
}
94+
8895
public String getHost() {
8996
return host;
9097
}
@@ -110,7 +117,7 @@ public TransportStrategy getTransportStrategy() {
110117
switch (transport) {
111118
case "TLS", "SSL":
112119
return TransportStrategy.SMTP_TLS;
113-
case "plain":
120+
case DEFAULT_TRANSPORT:
114121
default:
115122
return TransportStrategy.SMTP;
116123
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package stroom.analytics.impl;
2+
3+
import stroom.analytics.shared.AnalyticNotificationEmailDestination;
4+
5+
import org.junit.jupiter.api.Disabled;
6+
import org.junit.jupiter.api.Test;
7+
import org.junit.jupiter.api.extension.ExtendWith;
8+
import org.mockito.Mock;
9+
import org.mockito.Mockito;
10+
import org.mockito.junit.jupiter.MockitoExtension;
11+
12+
import java.util.UUID;
13+
14+
@ExtendWith(MockitoExtension.class)
15+
class TestEmailSender {
16+
17+
@Mock
18+
private AnalyticsConfig mockAnalyticsConfig;
19+
20+
@Disabled // manual only due to reliance on smtp.freesmtpservers.com
21+
@Test
22+
void send() {
23+
// See https://www.wpoven.com/tools/free-smtp-server-for-testing to check the email sent
24+
Mockito.when(mockAnalyticsConfig.getEmailConfig())
25+
.thenReturn(new EmailConfig(
26+
SmtpConfig.unauthenticated("smtp.freesmtpservers.com", 25),
27+
28+
"Mr Foo"));
29+
30+
final EmailSender emailSender = new EmailSender(() -> mockAnalyticsConfig);
31+
32+
final AnalyticNotificationEmailDestination destination = AnalyticNotificationEmailDestination.builder()
33+
34+
.build();
35+
36+
final Detection detection = new Detection(
37+
null,
38+
"DetectorName",
39+
UUID.randomUUID().toString(),
40+
null,
41+
null,
42+
"Headline",
43+
null,
44+
null,
45+
UUID.randomUUID().toString(),
46+
null,
47+
null,
48+
null,
49+
null);
50+
51+
emailSender.send(destination, detection);
52+
}
53+
}

stroom-app/src/test/java/stroom/db/migration/TestListDbMigrations.java

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.google.common.base.Strings;
99
import jakarta.validation.constraints.NotNull;
1010
import org.junit.jupiter.api.Test;
11+
import org.junit.jupiter.api.parallel.Isolated;
1112
import org.slf4j.Logger;
1213
import org.slf4j.LoggerFactory;
1314

@@ -31,6 +32,8 @@
3132
import static stroom.util.ConsoleColour.RED;
3233
import static stroom.util.ConsoleColour.YELLOW;
3334

35+
@Isolated // This is walking the file tree so doesn't like it if another test is mutating
36+
// the file tree at the same time.
3437
public class TestListDbMigrations {
3538

3639
private static final Logger LOGGER = LoggerFactory.getLogger(TestListDbMigrations.class);

stroom-core-client-widget/src/main/java/stroom/widget/popup/client/event/ShowPopupEvent.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import stroom.widget.popup.client.presenter.PopupSize;
2222
import stroom.widget.popup.client.presenter.PopupType;
2323

24+
import com.google.gwt.core.client.GWT;
2425
import com.google.gwt.dom.client.Element;
2526
import com.google.gwt.event.shared.EventHandler;
2627
import com.google.gwt.event.shared.GwtEvent;
@@ -199,7 +200,6 @@ public Builder modeless() {
199200
}
200201

201202
public Builder addAutoHidePartner(final Element... autoHidePartner) {
202-
203203
this.autoHidePartners.addAll(GwtNullSafe.asList(autoHidePartner));
204204
return this;
205205
}
@@ -222,17 +222,21 @@ public Builder onHide(final HidePopupEvent.Handler handler) {
222222
public void fire() {
223223
// By default, we will automatically hide popups unless they have a handler that alters the behaviour.
224224
if (hideRequestHandler == null) {
225-
hideRequestHandler = e -> HidePopupEvent.builder(presenterWidget)
226-
.autoClose(e.isAutoClose())
227-
.ok(e.isOk())
228-
.fire();
225+
hideRequestHandler = e -> {
226+
GWT.log("isOk: " + e.isOk());
227+
HidePopupEvent.builder(presenterWidget)
228+
.autoClose(e.isAutoClose())
229+
.ok(e.isOk())
230+
.fire();
231+
};
229232
}
230233

231234
Element[] elements = null;
232235
if (GwtNullSafe.hasItems(autoHidePartners)) {
233236
elements = autoHidePartners.toArray(new Element[0]);
234237
}
235238

239+
// if (!presenterWidget.getView().asWidget().isVisible()) {
236240
presenterWidget.fireEvent(new ShowPopupEvent(
237241
presenterWidget,
238242
popupType,
@@ -244,6 +248,7 @@ public void fire() {
244248
hideHandler,
245249
modal,
246250
elements));
251+
// }
247252
}
248253
}
249254
}

stroom-core-client/src/main/java/stroom/dashboard/client/main/SearchModel.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.Map;
5050
import java.util.Map.Entry;
5151
import java.util.function.Consumer;
52+
import java.util.stream.Collectors;
5253

5354
public class SearchModel {
5455

@@ -400,15 +401,12 @@ private void poll(Fetch fetch, final boolean storeHistory) {
400401
* @return A result component map.
401402
*/
402403
private Map<String, ComponentSettings> createComponentSettingsMap() {
403-
if (componentMap.size() > 0) {
404-
final Map<String, ComponentSettings> resultComponentMap = new HashMap<>();
405-
for (final Entry<String, ResultComponent> entry : componentMap.entrySet()) {
406-
final String componentId = entry.getKey();
407-
final ResultComponent resultComponent = entry.getValue();
408-
final ComponentSettings componentSettings = resultComponent.getSettings();
409-
resultComponentMap.put(componentId, componentSettings);
410-
}
411-
return resultComponentMap;
404+
if (!componentMap.isEmpty()) {
405+
return componentMap.entrySet()
406+
.stream()
407+
.collect(Collectors.toMap(
408+
Entry::getKey,
409+
entry -> entry.getValue().getSettings()));
412410
}
413411
return null;
414412
}

stroom-core-client/src/main/java/stroom/entity/client/presenter/InfoDocumentPresenter.java

+24-10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class InfoDocumentPresenter
5050
implements ShowInfoDocumentDialogEvent.Handler {
5151

5252
private final DateTimeFormatter dateTimeFormatter;
53+
private boolean isShowing = false;
5354

5455
@Inject
5556
public InfoDocumentPresenter(final EventBus eventBus,
@@ -68,13 +69,23 @@ protected void onBind() {
6869

6970
@Override
7071
protected void revealInParent() {
71-
final PopupSize popupSize = PopupSize.resizable(500, 500);
72-
ShowPopupEvent.builder(this)
73-
.popupType(PopupType.CLOSE_DIALOG)
74-
.popupSize(popupSize)
75-
.caption("Info")
76-
.onShow(e -> getView().focus())
77-
.fire();
72+
// Popup is not modal so, allow the user to click Info for another doc
73+
// which will just update the view and not need a new show event.
74+
if (!isShowing) {
75+
final PopupSize popupSize = PopupSize.resizable(500, 500);
76+
ShowPopupEvent.builder(this)
77+
.popupType(PopupType.CLOSE_DIALOG)
78+
.popupSize(popupSize)
79+
.caption("Info")
80+
.onShow(e -> {
81+
getView().focus();
82+
isShowing = true;
83+
})
84+
.onHide(e -> {
85+
isShowing = false;
86+
})
87+
.fire();
88+
}
7889
}
7990

8091
@ProxyEvent
@@ -135,8 +146,6 @@ public void onCreate(final ShowInfoDocumentDialogEvent event) {
135146
.sorted()
136147
.forEach(tag ->
137148
appendLine("\t", tag, sb));
138-
139-
140149
// sb.append(CopyTextUtil.div("infoLine", sbInner.toSafeHtml()));
141150
}
142151

@@ -156,11 +165,12 @@ private void appendKey(final String key, final SafeHtmlBuilder sb) {
156165
sb.appendHtmlConstant("<b>");
157166
sb.appendEscaped(key);
158167
sb.appendHtmlConstant("</b>");
159-
if (key.trim().length() > 0) {
168+
if (!GwtNullSafe.isBlankString(key)) {
160169
sb.appendEscaped(": ");
161170
}
162171
}
163172

173+
164174
// --------------------------------------------------------------------------------
165175

166176

@@ -169,6 +179,10 @@ public interface InfoDocumentView extends View, Focus {
169179
void setInfo(SafeHtml info);
170180
}
171181

182+
183+
// --------------------------------------------------------------------------------
184+
185+
172186
@ProxyCodeSplit
173187
public interface InfoDocumentProxy extends Proxy<InfoDocumentPresenter> {
174188

stroom-core-client/src/main/java/stroom/query/client/presenter/QueryEditPresenter.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import stroom.query.client.presenter.QueryEditPresenter.QueryEditView;
3939
import stroom.query.client.view.QueryResultTabsView;
4040
import stroom.util.shared.DefaultLocation;
41+
import stroom.util.shared.GwtNullSafe;
4142
import stroom.util.shared.Indicators;
4243
import stroom.util.shared.Severity;
4344
import stroom.util.shared.StoredError;
@@ -60,6 +61,7 @@
6061

6162
import java.util.Collections;
6263
import java.util.List;
64+
import java.util.Objects;
6365
import java.util.Set;
6466
import java.util.function.Function;
6567
import javax.inject.Provider;
@@ -154,7 +156,7 @@ public void setData(final Result componentResult) {
154156
}
155157

156158
final QLVisResult visResult = (QLVisResult) componentResult;
157-
if (visResult.getJsonData() != null && visResult.getJsonData().length() > 0) {
159+
if (!GwtNullSafe.isBlankString(visResult.getJsonData())) {
158160
hasData = true;
159161
setVisHidden(false);
160162
}
@@ -339,7 +341,10 @@ private void stop() {
339341

340342
private void run(final boolean incremental,
341343
final boolean storeHistory) {
342-
queryInfo.prompt(() -> run(incremental, storeHistory, Function.identity()));
344+
// No point running the search if there is no query
345+
if (!GwtNullSafe.isBlankString(editorPresenter.getText())) {
346+
queryInfo.prompt(() -> run(incremental, storeHistory, Function.identity()));
347+
}
343348
}
344349

345350
private void run(final boolean incremental,
@@ -361,7 +366,6 @@ private void run(final boolean incremental,
361366
incremental,
362367
storeHistory,
363368
queryInfo.getMessage());
364-
// }
365369
}
366370

367371
public TimeRange getTimeRange() {
@@ -378,7 +382,8 @@ public void setQuery(final DocRef docRef, final String query, final boolean read
378382
queryModel.init(docRef.getUuid());
379383
if (query != null) {
380384
reading = true;
381-
if (editorPresenter.getText().length() == 0 || !editorPresenter.getText().equals(query)) {
385+
if (GwtNullSafe.isBlankString(editorPresenter.getText())
386+
|| !Objects.equals(editorPresenter.getText(), query)) {
382387
editorPresenter.setText(query);
383388
queryHelpPresenter.setQuery(query);
384389
}

0 commit comments

Comments
 (0)