Skip to content

Commit

Permalink
Rename notification type class to UpdateAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
renner committed Sep 8, 2023
1 parent b6a5c94 commit 13267f4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.redhat.rhn.domain.notification.types.PaygAuthenticationUpdateFailed;
import com.redhat.rhn.domain.notification.types.StateApplyFailed;
import com.redhat.rhn.domain.notification.types.SubscriptionWarning;
import com.redhat.rhn.domain.notification.types.UpdateAvailableNotification;
import com.redhat.rhn.domain.notification.types.UpdateAvailable;

import com.google.gson.Gson;

Expand Down Expand Up @@ -135,8 +135,8 @@ public NotificationData getNotificationData() {
return new Gson().fromJson(getData(), EndOfLifePeriod.class);
case SubscriptionWarning:
return new Gson().fromJson(getData(), SubscriptionWarning.class);
case UpdateAvailableNotification:
return new Gson().fromJson(getData(), UpdateAvailableNotification.class);
case UpdateAvailable:
return new Gson().fromJson(getData(), UpdateAvailable.class);
default: throw new RuntimeException("Notification type not found");
}
}
Expand All @@ -156,7 +156,7 @@ public String getTypeAsString() {
case PaygAuthenticationUpdateFailed: return "PAYG refresh failed";
case EndOfLifePeriod: return "End of Life Period";
case SubscriptionWarning: return "Subscription Warning";
case UpdateAvailableNotification: return "Updates are Available";
case UpdateAvailable: return "Updates are Available";
default: return getType().name();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ public enum NotificationType {
PaygAuthenticationUpdateFailed,
EndOfLifePeriod,
SubscriptionWarning,
UpdateAvailableNotification,
UpdateAvailable,
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
package com.redhat.rhn.domain.notification.types;


import com.redhat.rhn.common.conf.ConfigDefaults;
import com.redhat.rhn.common.localization.LocalizationService;
import com.redhat.rhn.domain.notification.NotificationMessage;
Expand All @@ -25,10 +24,13 @@

import java.io.IOException;

public class UpdateAvailableNotification implements NotificationData {
/**
* Notification data for an update being available for the server.
*/
public class UpdateAvailable implements NotificationData {

private static final LocalizationService LOCALIZATION_SERVICE = LocalizationService.getInstance();
private static final Logger LOG = LogManager.getLogger(UpdateAvailableNotification.class);
private static final Logger LOG = LogManager.getLogger(UpdateAvailable.class);
private static final String UYUNI_PATCH_REPO = "systemsmanagement_Uyuni_Stable_Patches";
private static final String UYUNI_UPDATE_REPO = "systemsmanagement_Uyuni_Stable";

Expand All @@ -41,7 +43,7 @@ public class UpdateAvailableNotification implements NotificationData {
*
* @param runtimeIn runtime object for command execution
*/
public UpdateAvailableNotification(Runtime runtimeIn) {
public UpdateAvailable(Runtime runtimeIn) {
this.runtime = runtimeIn;
}

Expand Down Expand Up @@ -85,7 +87,7 @@ public NotificationMessage.NotificationMessageSeverity getSeverity() {

@Override
public NotificationType getType() {
return NotificationType.UpdateAvailableNotification;
return NotificationType.UpdateAvailable;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.redhat.rhn.common.conf.ConfigDefaults;
import com.redhat.rhn.domain.notification.NotificationMessage;
import com.redhat.rhn.domain.notification.types.NotificationType;
import com.redhat.rhn.domain.notification.types.UpdateAvailableNotification;
import com.redhat.rhn.domain.notification.types.UpdateAvailable;
import com.redhat.rhn.testing.MockObjectTestCase;

import org.jmock.Expectations;
Expand All @@ -45,8 +45,8 @@ public void setUp() {

@Test
public void testPropertiesAndStrings() {
UpdateAvailableNotification notification = new UpdateAvailableNotification(runtimeMock);
assertEquals(NotificationType.UpdateAvailableNotification, notification.getType());
UpdateAvailable notification = new UpdateAvailable(runtimeMock);
assertEquals(NotificationType.UpdateAvailable, notification.getType());
assertEquals(NotificationMessage.NotificationMessageSeverity.warning, notification.getSeverity());
assertEquals("Updates are available.", notification.getSummary());
if (ConfigDefaults.get().isUyuni()) {
Expand Down Expand Up @@ -77,7 +77,7 @@ public void testUpdatesAvailable() {
e.printStackTrace();
}

UpdateAvailableNotification notification = new UpdateAvailableNotification(runtimeMock);
UpdateAvailable notification = new UpdateAvailable(runtimeMock);
assertTrue(notification.updateAvailable());
}

Expand All @@ -97,7 +97,7 @@ public void testNoUpdatesAvailable() {
e.printStackTrace();
}

UpdateAvailableNotification notification = new UpdateAvailableNotification(runtimeMock);
UpdateAvailable notification = new UpdateAvailable(runtimeMock);
assertFalse(notification.updateAvailable());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.redhat.rhn.domain.notification.UserNotificationFactory;
import com.redhat.rhn.domain.notification.types.EndOfLifePeriod;
import com.redhat.rhn.domain.notification.types.SubscriptionWarning;
import com.redhat.rhn.domain.notification.types.UpdateAvailableNotification;
import com.redhat.rhn.domain.notification.types.UpdateAvailable;
import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.frontend.dto.ActionMessage;
Expand Down Expand Up @@ -142,7 +142,7 @@ private void processSubscriptionWarningNotification() {
}

private void processUpdateAvailableNotification() {
UpdateAvailableNotification uan = new UpdateAvailableNotification(Runtime.getRuntime());
UpdateAvailable uan = new UpdateAvailable(Runtime.getRuntime());
if (uan.updateAvailable()) {
NotificationMessage notificationMessage =
UserNotificationFactory.createNotificationMessage(uan);
Expand Down
2 changes: 1 addition & 1 deletion java/conf/rhn_java.conf
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ java.kiwi_os_image_building_enabled = true
java.notifications_lifetime = 30

# Configure the disablement of notification messages by type - example disabling all notification types
#java.notifications_type_disabled = OnboardingFailed,ChannelSyncFailed,ChannelSyncFinished,CreateBootstrapRepoFailed,StateApplyFailed,UpdateAvailableNotification,SubscriptionWarning
#java.notifications_type_disabled = OnboardingFailed,ChannelSyncFailed,ChannelSyncFinished,CreateBootstrapRepoFailed,StateApplyFailed,UpdateAvailable,SubscriptionWarning
java.notifications_type_disabled = ChannelSyncFinished

# Maximal number of parallel connections to refresh from SCC
Expand Down
4 changes: 2 additions & 2 deletions web/html/src/manager/notifications/notification-messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ const _MESSAGE_TYPE = {
id: "SubscriptionWarning",
text: t("Subscription Warning"),
},
UpdateAvailableNotification: {
id: "UpdateAvailableNotification",
UpdateAvailable: {
id: "UpdateAvailable",
text: t("Update Notification"),
},
};
Expand Down

0 comments on commit 13267f4

Please sign in to comment.