ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From avija...@apache.org
Subject ambari git commit: Revert "AMBARI-17004. Unit tests failing because of the order of hash sets/maps (Miklos Gergely via oleewere)"
Date Wed, 08 Jun 2016 17:07:30 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 28dc0e163 -> 5754b6826


Revert "AMBARI-17004. Unit tests failing because of the order of hash sets/maps (Miklos Gergely
via oleewere)"

This reverts commit 32890b5542dee84de30d127896fe2426af1926ee.


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

Branch: refs/heads/trunk
Commit: 5754b682687425913af5119f27d41fc2f9dd3cfd
Parents: 28dc0e1
Author: Aravindan Vijayan <avijayan@hortonworks.com>
Authored: Wed Jun 8 09:45:08 2016 -0700
Committer: Aravindan Vijayan <avijayan@hortonworks.com>
Committed: Wed Jun 8 10:06:45 2016 -0700

----------------------------------------------------------------------
 .../ChangeRepositoryVersionRequestAuditEvent.java        |  5 ++---
 .../request/ClusterPrivilegeChangeRequestAuditEvent.java |  4 +---
 .../eventcreator/RepositoryVersionEventCreator.java      | 10 ++++------
 .../eventcreator/RequestAuditEventCreatorHelper.java     |  5 ++---
 .../audit/request/creator/PrivilegeEventCreatorTest.java |  6 +++---
 .../request/creator/ViewPrivilegeEventCreatorTest.java   |  6 +++---
 .../internal/ComponentResourceProviderTest.java          |  9 +++------
 .../security/ldap/AmbariLdapDataPopulatorTest.java       | 11 +++++------
 8 files changed, 23 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ChangeRepositoryVersionRequestAuditEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ChangeRepositoryVersionRequestAuditEvent.java
b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ChangeRepositoryVersionRequestAuditEvent.java
index 702cd6f..74e7267 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ChangeRepositoryVersionRequestAuditEvent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ChangeRepositoryVersionRequestAuditEvent.java
@@ -20,7 +20,6 @@ package org.apache.ambari.server.audit.event.request;
 
 import java.util.List;
 import java.util.Map;
-import java.util.SortedMap;
 
 import javax.annotation.concurrent.Immutable;
 
@@ -58,7 +57,7 @@ public class ChangeRepositoryVersionRequestAuditEvent extends RequestAuditEvent
      * Details of the repositories
      * os type -> list of repositories, where a repository is a key-value map of the properties
(repo_id, repo_name, base_url)
      */
-    private SortedMap<String, List<Map<String, String>>> repos;
+    private Map<String, List<Map<String, String>>> repos;
 
     public ChangeRepositoryVersionAuditEventBuilder() {
       super.withOperation("Repository version change");
@@ -126,7 +125,7 @@ public class ChangeRepositoryVersionRequestAuditEvent extends RequestAuditEvent
       return this;
     }
 
-    public ChangeRepositoryVersionAuditEventBuilder withRepos(SortedMap<String, List<Map<String,
String>>> repos) {
+    public ChangeRepositoryVersionAuditEventBuilder withRepos(Map<String, List<Map<String,
String>>> repos) {
       this.repos = repos;
       return this;
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ClusterPrivilegeChangeRequestAuditEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ClusterPrivilegeChangeRequestAuditEvent.java
b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ClusterPrivilegeChangeRequestAuditEvent.java
index b28bb2a..cc59038 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ClusterPrivilegeChangeRequestAuditEvent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/ClusterPrivilegeChangeRequestAuditEvent.java
@@ -23,8 +23,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
 
 import javax.annotation.concurrent.Immutable;
 
@@ -69,7 +67,7 @@ public class ClusterPrivilegeChangeRequestAuditEvent extends RequestAuditEvent
{
     protected void buildAuditMessage(StringBuilder builder) {
       super.buildAuditMessage(builder);
 
-      SortedSet<String> roleSet = new TreeSet<String>();
+      Set<String> roleSet = new HashSet<String>();
       roleSet.addAll(users.keySet());
       roleSet.addAll(groups.keySet());
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
index bfe3226..2f09b74 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RepositoryVersionEventCreator.java
@@ -23,8 +23,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
 
 import org.apache.ambari.server.api.services.Request;
 import org.apache.ambari.server.api.services.Result;
@@ -137,9 +135,9 @@ public class RepositoryVersionEventCreator implements RequestAuditEventCreator
{
    * @param request
    * @return a map of repositories
    */
-  private SortedMap<String, List<Map<String, String>>> getRepos(Request
request) {
+  private Map<String, List<Map<String, String>>> getRepos(Request request)
{
 
-    SortedMap<String, List<Map<String, String>>> result = new TreeMap<String,
List<Map<String, String>>>();
+    Map<String, List<Map<String, String>>> result = new HashMap<String,
List<Map<String, String>>>();
 
     Map<String, Object> first = Iterables.getFirst(request.getBody().getPropertySets(),
null);
 
@@ -155,8 +153,8 @@ public class RepositoryVersionEventCreator implements RequestAuditEventCreator
{
    * @param set
    * @return
    */
-  private SortedMap<String, List<Map<String, String>>> createResultForOperationSystems(Set<Object>
set) {
-    SortedMap<String, List<Map<String, String>>> result = new TreeMap<String,
List<Map<String, String>>>();
+  private Map<String, List<Map<String, String>>> createResultForOperationSystems(Set<Object>
set) {
+    Map<String, List<Map<String, String>>> result = new HashMap<String,
List<Map<String, String>>>();
     for (Object entry : set) {
       if (entry instanceof Map) {
         Map<String, Object> map = (Map<String, Object>) entry;

http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
index 398b275..f7a6e36 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/RequestAuditEventCreatorHelper.java
@@ -85,9 +85,8 @@ public class RequestAuditEventCreatorHelper {
   public static List<String> getPropertyList(Request request, String propertyName)
{
     List<String> list = new LinkedList<String>();
     for (Map<String, Object> propertyMap : request.getBody().getPropertySets()) {
-      if (propertyMap.containsKey(propertyName)) {
-        list.add(String.valueOf(propertyMap.get(propertyName)));
-      }
+      String userName = String.valueOf(propertyMap.get(propertyName));
+      list.add(userName);
     }
     return list;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/PrivilegeEventCreatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/PrivilegeEventCreatorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/PrivilegeEventCreatorTest.java
index 5a805fc..ff4abd6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/PrivilegeEventCreatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/PrivilegeEventCreatorTest.java
@@ -97,11 +97,11 @@ public class PrivilegeEventCreatorTest extends AuditEventCreatorTestBase{
 
     String actual = event.getAuditMessage();
     String expected = "User(" + userName + "), RemoteIp(1.2.3.4), Operation(Role change),
RequestType(PUT), url(http://example.com:8080/api/v1/test), ResultStatus(200 OK), Roles(\n"
+
+      "Permission2: \n" +
+      "  Users: " + userName + "2\n" +
       "Permission1: \n" +
       "  Users: " + userName + "\n" +
-      "  Groups: testgroup\n" +
-      "Permission2: \n" +
-      "  Users: " + userName + "2)";
+      "  Groups: testgroup)";
 
     Assert.assertTrue("Class mismatch", event instanceof ClusterPrivilegeChangeRequestAuditEvent);
     Assert.assertEquals(expected, actual);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/ViewPrivilegeEventCreatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/ViewPrivilegeEventCreatorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/ViewPrivilegeEventCreatorTest.java
index 4685b72..ab2b068 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/ViewPrivilegeEventCreatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/ViewPrivilegeEventCreatorTest.java
@@ -75,11 +75,11 @@ public class ViewPrivilegeEventCreatorTest extends AuditEventCreatorTestBase{
 
     String actual = event.getAuditMessage();
     String expected = "User(" + userName + "), RemoteIp(1.2.3.4), Operation(View permission
change), RequestType(PUT), url(http://example.com:8080/api/v1/test), ResultStatus(200 OK),
Type(MyView), Version(MyView), Name(MyView), Permissions(\n" +
+      "Permission2: \n" +
+      "  Users: testuser2\n" +
       "Permission1: \n" +
       "  Users: testuser\n" +
-      "  Groups: testgroup\n" +
-      "Permission2: \n" +
-      "  Users: testuser2)";
+      "  Groups: testgroup)";
 
     Assert.assertTrue("Class mismatch", event instanceof ViewPrivilegeChangeRequestAuditEvent);
     Assert.assertEquals(expected, actual);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index cbf3044..d299fad 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -226,9 +226,6 @@ public class ComponentResourceProviderTest {
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);
     expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
     expect(cluster.getDesiredStackVersion()).andReturn(stackId);
-    expect(serviceComponent1.getName()).andReturn("Component100");
-    expect(serviceComponent2.getName()).andReturn("Component101");
-    expect(serviceComponent3.getName()).andReturn("Component102");
 
     expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes();
 
@@ -244,9 +241,9 @@ public class ComponentResourceProviderTest {
       new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null,
"", 1, 1, 0,
               true /* recovery enabled */, "Component102 Client"));
 
-    expect(ambariMetaInfo.getComponent(null, null, null, "Component100")).andReturn(componentInfo1);
-    expect(ambariMetaInfo.getComponent(null, null, null, "Component101")).andReturn(componentInfo2);
-    expect(ambariMetaInfo.getComponent(null, null, null, "Component102")).andReturn(componentInfo1);
+    expect(ambariMetaInfo.getComponent((String) anyObject(),
+        (String) anyObject(), (String) anyObject(), (String) anyObject()))
+        .andReturn(componentInfo1).times(2).andReturn(componentInfo2);
 
     expect(componentInfo1.getCategory()).andReturn("MASTER").anyTimes();
     expect(componentInfo2.getCategory()).andReturn("SLAVE").anyTimes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/5754b682/ambari-server/src/test/java/org/apache/ambari/server/security/ldap/AmbariLdapDataPopulatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/ldap/AmbariLdapDataPopulatorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/security/ldap/AmbariLdapDataPopulatorTest.java
index 2265eec..fbe233d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/security/ldap/AmbariLdapDataPopulatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/security/ldap/AmbariLdapDataPopulatorTest.java
@@ -303,17 +303,16 @@ public class AmbariLdapDataPopulatorTest {
     expect(users.getAllUsers()).andReturn(Collections.EMPTY_LIST);
     expect(configuration.getLdapServerProperties()).andReturn(new LdapServerProperties()).anyTimes();
 
+    Set<LdapGroupDto> groupDtos = Sets.newHashSet();
     LdapGroupDto group1Dto = new LdapGroupDto();
     group1Dto.setGroupName("group1");
     group1Dto.setMemberAttributes(Sets.newHashSet("group2"));
-    Set<LdapGroupDto> groupDtos1 = Sets.newHashSet();
-    groupDtos1.add(group1Dto);
 
     LdapGroupDto group2Dto = new LdapGroupDto();
     group2Dto.setGroupName("group2");
     group2Dto.setMemberAttributes(Collections.EMPTY_SET);
-    Set<LdapGroupDto> groupDtos2 = Sets.newHashSet();
-    groupDtos2.add(group2Dto);
+    groupDtos.add(group1Dto);
+    groupDtos.add(group2Dto);
 
     LdapBatchDto batchInfo = new LdapBatchDto();
     replay(configuration, users, group1, group2);
@@ -326,8 +325,8 @@ public class AmbariLdapDataPopulatorTest {
 
     expect(dataPopulator.getLdapUserByMemberAttr(anyString())).andReturn(null).anyTimes();
     expect(dataPopulator.getLdapGroupByMemberAttr("group2")).andReturn(group2Dto);
-    expect(dataPopulator.getLdapGroups("group1")).andReturn(groupDtos1).anyTimes();
-    expect(dataPopulator.getLdapGroups("group2")).andReturn(groupDtos2).anyTimes();
+    expect(dataPopulator.getLdapGroups("group1")).andReturn(groupDtos).anyTimes();
+    expect(dataPopulator.getLdapGroups("group2")).andReturn(groupDtos).anyTimes();
 
     replay(dataPopulator);
     // WHEN


Mime
View raw message