ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject ambari git commit: AMBARi-10964. Deleting a widget fails.
Date Wed, 06 May 2015 17:30:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 690dfde82 -> 4699a1b75


AMBARi-10964. Deleting a widget fails.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4699a1b7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4699a1b7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4699a1b7

Branch: refs/heads/trunk
Commit: 4699a1b75811aace747dc9c87072b29b8b41fbd1
Parents: 690dfde
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Wed May 6 10:30:23 2015 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Wed May 6 10:30:23 2015 -0700

----------------------------------------------------------------------
 .../internal/WidgetLayoutResourceProvider.java  |  4 ++--
 .../WidgetLayoutResourceProviderTest.java       | 22 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4699a1b7/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
index 68dc4e9..8f068d5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProvider.java
@@ -172,7 +172,7 @@ public class WidgetLayoutResourceProvider extends AbstractControllerResourceProv
             widgetLayoutUserWidgetEntity.setWidgetOrder(order++);
             widgetLayoutUserWidgetEntity.setWidgetLayout(entity);
             widgetLayoutUserWidgetEntityList.add(widgetLayoutUserWidgetEntity);
-
+            widgetEntity.getListWidgetLayoutUserWidgetEntity().add(widgetLayoutUserWidgetEntity);
           }
 
           entity.setListWidgetLayoutUserWidgetEntity(widgetLayoutUserWidgetEntityList);
@@ -301,7 +301,7 @@ public class WidgetLayoutResourceProvider extends AbstractControllerResourceProv
             widgetLayoutUserWidgetEntity.setWidgetOrder(order++);
             widgetLayoutUserWidgetEntity.setWidgetLayout(entity);
             widgetLayoutUserWidgetEntityList.add(widgetLayoutUserWidgetEntity);
-
+            widgetEntity.getListWidgetLayoutUserWidgetEntity().add(widgetLayoutUserWidgetEntity);
           }
 
           entity.setListWidgetLayoutUserWidgetEntity(widgetLayoutUserWidgetEntityList);

http://git-wip-us.apache.org/repos/asf/ambari/blob/4699a1b7/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
index dda0598..1a9e230 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetLayoutResourceProviderTest.java
@@ -31,7 +31,9 @@ import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.metadata.ActionMetadata;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.dao.WidgetDAO;
 import org.apache.ambari.server.orm.dao.WidgetLayoutDAO;
+import org.apache.ambari.server.orm.entities.WidgetEntity;
 import org.apache.ambari.server.orm.entities.WidgetLayoutEntity;
 import org.apache.ambari.server.orm.entities.WidgetLayoutUserWidgetEntity;
 import org.apache.ambari.server.state.Cluster;
@@ -42,6 +44,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -51,6 +54,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import static org.easymock.EasyMock.anyLong;
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.capture;
 import static org.easymock.EasyMock.createMock;
@@ -68,11 +72,13 @@ import static org.junit.Assert.assertEquals;
 public class WidgetLayoutResourceProviderTest {
 
   private WidgetLayoutDAO dao = null;
+  private WidgetDAO widgetDAO = null;
   private Injector m_injector;
 
   @Before
   public void before() {
     dao = createStrictMock(WidgetLayoutDAO.class);
+    widgetDAO = createStrictMock(WidgetDAO.class);
 
     m_injector = Guice.createInjector(Modules.override(
         new InMemoryDefaultTestModule()).with(new MockModule()));
@@ -155,7 +161,12 @@ public class WidgetLayoutResourceProviderTest {
     dao.create(capture(entityCapture));
     expectLastCall();
 
-    replay(amc, clusters, cluster, dao);
+    WidgetEntity widgetEntity = new WidgetEntity();
+    widgetEntity.setId(1l);
+    widgetEntity.setListWidgetLayoutUserWidgetEntity(new ArrayList<WidgetLayoutUserWidgetEntity>());
+    expect(widgetDAO.findById(anyLong())).andReturn(widgetEntity).anyTimes();
+
+    replay(amc, clusters, cluster, dao, widgetDAO);
 
     WidgetLayoutResourceProvider provider = createProvider(amc);
 
@@ -167,6 +178,9 @@ public class WidgetLayoutResourceProviderTest {
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_USERNAME_PROPERTY_ID, "admin");
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_SCOPE_PROPERTY_ID, "CLUSTER");
     Set widgetsInfo = new LinkedHashSet();
+    Map<String, String> widget = new HashMap<String, String>();
+    widget.put("id","1");
+    widgetsInfo.add(widget);
     requestProps.put(WidgetLayoutResourceProvider.WIDGETLAYOUT_WIDGETS_PROPERTY_ID, widgetsInfo);
 
     Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps),
null);
@@ -184,8 +198,11 @@ public class WidgetLayoutResourceProviderTest {
     Assert.assertEquals("section_name", entity.getSectionName());
     Assert.assertEquals("admin", entity.getUserName());
     Assert.assertNotNull(entity.getListWidgetLayoutUserWidgetEntity());
+    Assert.assertNotNull(entity.getListWidgetLayoutUserWidgetEntity().get(0));
+    Assert.assertNotNull(entity.getListWidgetLayoutUserWidgetEntity().get(0).
+            getWidget().getListWidgetLayoutUserWidgetEntity());
 
-    verify(amc, clusters, cluster, dao);
+    verify(amc, clusters, cluster, dao, widgetDAO);
   }
 
   /**
@@ -359,6 +376,7 @@ public class WidgetLayoutResourceProviderTest {
       binder.bind(Cluster.class).toInstance(
           EasyMock.createNiceMock(Cluster.class));
       binder.bind(ActionMetadata.class);
+      binder.bind(WidgetDAO.class).toInstance(widgetDAO);
     }
   }
 }


Mime
View raw message