Author: [email protected]
Date: Thu Jan 19 14:48:30 2012
New Revision: 1945
Log:
AMDATU-494 Added TenantService / Renamed unit test and package to match
TenantService naming
Added:
trunk/amdatu-core/tenant-factory/src/main/java/org/amdatu/core/tenant/factory/TenantService.java
trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/core/
trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/core/tenant/
trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/core/tenant/factory/
trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/core/tenant/factory/TenantServiceTest.java
- copied, changed from r1944,
/trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/test/unit/TenantEntityTest.java
Modified:
trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/test/
Added:
trunk/amdatu-core/tenant-factory/src/main/java/org/amdatu/core/tenant/factory/TenantService.java
==============================================================================
--- (empty file)
+++
trunk/amdatu-core/tenant-factory/src/main/java/org/amdatu/core/tenant/factory/TenantService.java
Thu Jan 19 14:48:30 2012
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010, 2011 The Amdatu Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.amdatu.core.tenant.factory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.amdatu.core.tenant.Tenant;
+
+/**
+ * Data-object representing a Tenant.
+ *
+ * @author <a href="mailto:[email protected]">Amdatu Project
Team</a>
+ */
+public class TenantService implements Tenant {
+ private final String m_id;
+ private final Map<String, String> m_properties = new HashMap<String,
String>();
+
+ private String m_name;
+
+ public TenantService(String id, String name, Map<String, String>
properties) {
+ if (id == null) {
+ throw new NullPointerException("id cannot be null");
+ }
+ m_id = id;
+ m_name = name;
+ if (properties != null) {
+ m_properties.putAll(properties);
+ }
+ }
+
+ public TenantService(String id, String name) {
+ this(id, name, new HashMap<String, String>());
+ }
+
+ public String getId() {
+ return m_id;
+ }
+
+ public String getName() {
+ return m_name;
+ }
+
+ public void setName(String name) {
+ m_name = name;
+ }
+
+ public Map<String, String> getProperties() {
+ return new HashMap<String, String>(m_properties);
+ }
+
+ public void putProperty(String key, String value) {
+ m_properties.put(key, value);
+ }
+
+ public String toString() {
+ return m_name + " (" + m_id + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ return m_id.hashCode() * 31;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TenantService other = (TenantService) obj;
+ if (getId() == null && other.getId() != null)
+ return false;
+ if (getId() != null && other.getId() == null)
+ return false;
+ return getId().equals(other.getId());
+ }
+
+ public boolean matches(Map<String, String> properties) {
+ for (String key : properties.keySet()) {
+ if (!m_properties.containsKey(key)) {
+ return false;
+ }
+ else if (!m_properties.get(key).equals(properties.get(key))) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
Copied:
trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/core/tenant/factory/TenantServiceTest.java
(from r1944,
/trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/test/unit/TenantEntityTest.java)
==============================================================================
---
/trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/test/unit/TenantEntityTest.java
(original)
+++
trunk/amdatu-core/tenant-factory/src/test/java/org/amdatu/core/tenant/factory/TenantServiceTest.java
Thu Jan 19 14:48:30 2012
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.amdatu.test.unit;
+package org.amdatu.core.tenant.factory;
import org.amdatu.core.tenant.factory.TenantService;
import org.junit.Assert;
import org.junit.Test;
-public class TenantEntityTest {
+public class TenantServiceTest {
@Test
// AMDATU-260
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits