[#55] Add displayTitle to Alert

These changes simply add a field called
'displayTitle' to the Alert class to hold
a human-readable title for each Alert instance.

Closes #55.
This commit is contained in:
apldev1 2018-11-20 13:16:15 -05:00 committed by apldev3
parent c4bc52bd42
commit 3c5a657c17
2 changed files with 33 additions and 0 deletions

View File

@ -45,6 +45,9 @@ public class Alert extends ArchivableEntity {
@Column(name = "device_name")
private String deviceName;
@Column(name = "display_title", nullable = true)
private String displayTitle;
@Column(name = "details")
private String details;
@ -350,6 +353,24 @@ public class Alert extends ArchivableEntity {
this.deviceName = deviceName;
}
/**
* Get the display title associated with this Alert.
*
* @return the display title if one has been set, and null otherwise
*/
public String getDisplayTitle() {
return displayTitle;
}
/**
* Set the display title for this alert.
*
* @param displayTitle the desired display title (may be null)
*/
public void setDisplayTitle(final String displayTitle) {
this.displayTitle = displayTitle;
}
/**
* Returns a user-readable description of the details of the alert. The
* exact contents will be source-dependent.

View File

@ -19,6 +19,7 @@ public final class AlertTest {
private static final String TEST_DEVICE_NAME = "MyTestDevice";
private static final String RESOLVE_DESCRIPTION = "Record was added to baseline";
private static final String TEST_BASELINE_NAME = "Alert Test Baseline";
private static final String TEST_DISPLAY_TITLE = "Display Title";
/**
* Tests that default values are applied by the public Alert constructor.
@ -29,6 +30,7 @@ public final class AlertTest {
Assert.assertEquals(alert.getSeverity(), Alert.Severity.UNSPECIFIED);
Assert.assertEquals(alert.getType(), Alert.AlertType.UNSPECIFIED);
Assert.assertEquals(alert.getSource(), Alert.Source.UNSPECIFIED);
Assert.assertNull(alert.getDisplayTitle());
}
/**
@ -50,6 +52,16 @@ public final class AlertTest {
Assert.assertEquals(alert.getDetails(), TEST_DETAILS);
}
/**
* Test that the details can be set and retrieved.
*/
@Test
public void testDisplayTitle() {
Alert alert = new Alert(TEST_DETAILS);
alert.setDisplayTitle(TEST_DISPLAY_TITLE);
Assert.assertEquals(alert.getDisplayTitle(), TEST_DISPLAY_TITLE);
}
/**
* Test that the <code>Report</code> can be set and retrieved.
*/