2  * Copyright © 2016-2017 European Support Limited
 
   4  * Licensed under the Apache License, Version 2.0 (the "License");
 
   5  * you may not use this file except in compliance with the License.
 
   6  * You may obtain a copy of the License at
 
   8  *     http://www.apache.org/licenses/LICENSE-2.0
 
  10  * Unless required by applicable law or agreed to in writing, software
 
  11  * distributed under the License is distributed on an "AS IS" BASIS,
 
  12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  13  * See the License for the specific language governing permissions and
 
  14  * limitations under the License.
 
  17 package org.openecomp.core.zusammen.plugin.collaboration;
 
  19 import com.amdocs.zusammen.datatypes.Id;
 
  20 import com.amdocs.zusammen.datatypes.SessionContext;
 
  21 import com.amdocs.zusammen.datatypes.UserInfo;
 
  22 import com.amdocs.zusammen.datatypes.item.ElementContext;
 
  23 import com.amdocs.zusammen.datatypes.item.Info;
 
  24 import com.amdocs.zusammen.datatypes.item.ItemVersion;
 
  25 import com.amdocs.zusammen.datatypes.item.ItemVersionData;
 
  26 import com.amdocs.zusammen.datatypes.item.Relation;
 
  28 import java.util.Arrays;
 
  30 public class TestUtils {
 
  32   public static SessionContext createSessionContext(UserInfo user, String tenant) {
 
  33     SessionContext context = new SessionContext();
 
  34     context.setUser(user);
 
  35     context.setTenant(tenant);
 
  39   public static ElementContext createElementContext(Id itemId, Id versionId) {
 
  40     ElementContext elementContext = new ElementContext();
 
  41     elementContext.setItemId(itemId);
 
  42     elementContext.setVersionId(versionId);
 
  43     return elementContext;
 
  46   public static Info createInfo(String value) {
 
  47     Info info = new Info();
 
  49     info.addProperty("Name", "name_" + value);
 
  50     info.addProperty("Desc", "desc_" + value);
 
  54   public static ItemVersion createItemVersion(Id id, Id baseId, String name, boolean dirty) {
 
  55     ItemVersion version = new ItemVersion();
 
  57     version.setBaseId(baseId);
 
  58     ItemVersionData data = new ItemVersionData();
 
  59     data.setInfo(TestUtils.createInfo(name));
 
  60     data.setRelations(Arrays.asList(new Relation(), new Relation()));
 
  61     version.setData(data);