Refactor construction of application objects
- Use a builder and make the constructors private for DefaultApplication
- Make DefaultApplication immutable
- Use a builder and make the constructors private for DefaultApplicationDescription
- Make DefaultApplicationDescription immutable
Change-Id: I9499981bd2c0f48aede40682260d51eeae2cab98
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java
index ec05afb..c904455 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleApplicationStore.java
@@ -76,20 +76,11 @@
ApplicationId appId = idStore.registerApplication(name);
ApplicationDescription appDesc = getApplicationDescription(name);
DefaultApplication app =
- new DefaultApplication(appId,
- appDesc.version(),
- appDesc.title(),
- appDesc.description(),
- appDesc.origin(),
- appDesc.category(),
- appDesc.url(),
- appDesc.readme(),
- appDesc.icon(),
- appDesc.role(),
- appDesc.permissions(),
- appDesc.featuresRepo(),
- appDesc.features(),
- appDesc.requiredApps());
+ DefaultApplication
+ .builder(appDesc)
+ .withAppId(appId)
+ .build();
+
apps.put(appId, app);
states.put(appId, isActive(name) ? INSTALLED : ACTIVE);
// load app permissions
@@ -129,20 +120,11 @@
ApplicationDescription appDesc = saveApplication(appDescStream);
ApplicationId appId = idStore.registerApplication(appDesc.name());
DefaultApplication app =
- new DefaultApplication(appId,
- appDesc.version(),
- appDesc.title(),
- appDesc.description(),
- appDesc.origin(),
- appDesc.category(),
- appDesc.url(),
- appDesc.readme(),
- appDesc.icon(),
- appDesc.role(),
- appDesc.permissions(),
- appDesc.featuresRepo(),
- appDesc.features(),
- appDesc.requiredApps());
+ DefaultApplication
+ .builder(appDesc)
+ .withAppId(appId)
+ .build();
+
apps.put(appId, app);
states.put(appId, INSTALLED);
delegate.notify(new ApplicationEvent(APP_INSTALLED, app));