Browse code

FEATBL-807 Feat: handle calendar resource templates

Vincent Vignaud authored on 13/06/2019 07:53:42
Showing 21 changed files
... ...
@@ -91,4 +91,15 @@ public class VEventSeries {
91 91
 		return main != null ? main : occurrences.get(0);
92 92
 	}
93 93
 
94
+	public List<VEvent> flatten() {
95
+		final List<VEvent> evts = new ArrayList<>();
96
+		if (this.main != null) {
97
+			evts.add(this.main);
98
+		}
99
+		this.occurrences.forEach(occurrence -> {
100
+			evts.add(occurrence);
101
+		});
102
+		return evts;
103
+	}
104
+
94 105
 }
... ...
@@ -45,4 +45,5 @@ Import-Package: net.bluemind.addressbook.domainbook,
45 45
  net.bluemind.document.persistance.fs,
46 46
  net.bluemind.document.storage,
47 47
  net.bluemind.mailbox.persistance,
48
+ net.bluemind.resource.persistance,
48 49
  org.joda.time
... ...
@@ -1551,7 +1551,7 @@ public class IcsHookTests {
1551 1551
 		assertEquals(1, series.value.occurrences.size());
1552 1552
 		assertEquals(VEvent.ParticipationStatus.Accepted, series.value.occurrences.get(0).attendees.get(0).partStatus);
1553 1553
 	}
1554
-	
1554
+
1555 1555
 	@Test
1556 1556
 	public void a2o_MasterAttendee_accept_OccurrenceAttendee() throws Exception {
1557 1557
 		ItemValue<VEventSeries> oldEvent = defaultVEventWithAttendeeAndSimpleRecur("invite", "u2", "u2@test.lan");
... ...
@@ -115,7 +115,7 @@ public class IcsHook implements ICalendarHook {
115 115
 				sendEventInvitations(message);
116 116
 			} else {
117 117
 				DirEntry dirEntry = getMyDirEntry(message);
118
-				List<VEvent> flat = flatten(message.vevent);
118
+				List<VEvent> flat = message.vevent.flatten();
119 119
 				for (VEvent vEvent : flat) {
120 120
 					Optional<EventAttendeeTuple> attendee = getMatchingAttendeeForEvent(vEvent, dirEntry);
121 121
 					if (attendee.isPresent()) {
... ...
@@ -138,7 +138,7 @@ public class IcsHook implements ICalendarHook {
138 138
 		}
139 139
 
140 140
 		VEventSeries oldEventSeries = message.oldEvent;
141
-		List<VEvent> flatten = flatten(updatedEvent);
141
+		List<VEvent> flatten = updatedEvent.flatten();
142 142
 		try {
143 143
 			if (isMasterVersion(message.oldEvent, message.container)) {
144 144
 				onMasterVersionUpdated(message, updatedEvent, oldEventSeries, flatten);
... ...
@@ -223,6 +223,7 @@ public class IcsHook implements ICalendarHook {
223 223
 			deletedAttendees = deletedAttendees.stream().filter(a -> {
224 224
 				return !userDeletedFromSeries.contains(a);
225 225
 			}).collect(Collectors.toList());
226
+
226 227
 			if (!evt.exception()) {
227 228
 				userDeletedFromSeries.addAll(deletedAttendees);
228 229
 			}
... ...
@@ -349,7 +350,7 @@ public class IcsHook implements ICalendarHook {
349 350
 		List<Attendee> seriesAttendees = master != null ? master.attendees.stream().filter(a -> {
350 351
 			return attendsToSeries(message.vevent, a);
351 352
 		}).collect(Collectors.toList()) : Collections.emptyList();
352
-		List<VEvent> events = flatten(message.vevent);
353
+		List<VEvent> events = message.vevent.flatten();
353 354
 
354 355
 		for (VEvent evt : events) {
355 356
 			for (Attendee attendee : evt.attendees) {
... ...
@@ -448,7 +449,7 @@ public class IcsHook implements ICalendarHook {
448 449
 			return attendsToSeries(message.vevent, a);
449 450
 		}).collect(Collectors.toList()) : Collections.emptyList();
450 451
 
451
-		List<VEvent> events = flatten(message.vevent);
452
+		List<VEvent> events = message.vevent.flatten();
452 453
 
453 454
 		for (VEvent evt : events) {
454 455
 			for (Attendee attendee : evt.attendees) {
... ...
@@ -849,13 +850,13 @@ public class IcsHook implements ICalendarHook {
849 850
 	}
850 851
 
851 852
 	private VEventSeries getSeriesForAttendee(VEventSeries updatedEvent, Attendee attendee) {
852
-		return flatten(updatedEvent).stream() //
853
+		return updatedEvent.flatten().stream() //
853 854
 				.filter(evt -> userAttends(evt, attendee)) //
854 855
 				.reduce(new VEventSeries(), reduceSeries(), combineSeries());
855 856
 	}
856 857
 
857 858
 	private VEventSeries reduceToAttendee(VEventSeries updatedEvent, Attendee attendee) {
858
-		return flatten(updatedEvent).stream() //
859
+		return updatedEvent.flatten().stream() //
859 860
 				.map(evt -> {
860 861
 					evt.attendees = Arrays.asList(attendee);
861 862
 					return evt;
... ...
@@ -1022,7 +1023,7 @@ public class IcsHook implements ICalendarHook {
1022 1023
 
1023 1024
 	private boolean attendsToSeries(VEventSeries series, Attendee attendee) {
1024 1025
 		boolean attends = true;
1025
-		List<VEvent> flatten = flatten(series);
1026
+		List<VEvent> flatten = series.flatten();
1026 1027
 		for (VEvent vEvent : flatten) {
1027 1028
 			attends = attends && userAttends(vEvent, attendee);
1028 1029
 		}
... ...
@@ -1083,10 +1084,6 @@ public class IcsHook implements ICalendarHook {
1083 1084
 		return dirEntry.entryUid.equals(container.owner);
1084 1085
 	}
1085 1086
 
1086
-	/**
1087
-	 *
1088
-	 */
1089
-
1090 1087
 	private IServiceProvider provider() {
1091 1088
 		return ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM);
1092 1089
 	}
... ...
@@ -1101,17 +1098,6 @@ public class IcsHook implements ICalendarHook {
1101 1098
 		}
1102 1099
 	}
1103 1100
 
1104
-	private List<VEvent> flatten(VEventSeries vEvents) {
1105
-		List<VEvent> evts = new ArrayList<>();
1106
-		if (vEvents.main != null) {
1107
-			evts.add(vEvents.main);
1108
-		}
1109
-		vEvents.occurrences.forEach(occurrence -> {
1110
-			evts.add(occurrence);
1111
-		});
1112
-		return evts;
1113
-	}
1114
-
1115 1101
 	private static class MailData {
1116 1102
 		public final Organizer organizer;
1117 1103
 		public final String subject;
... ...
@@ -1190,4 +1176,5 @@ public class IcsHook implements ICalendarHook {
1190 1176
 		}
1191 1177
 
1192 1178
 	}
1179
+
1193 1180
 }
... ...
@@ -32,6 +32,19 @@ public class VEventMessage {
32 32
 	public Container container;
33 33
 	public String auditEventId;
34 34
 
35
+	public VEventMessage() {
36
+	}
37
+
38
+	public VEventMessage(final VEventSeries vevent, final String uid, boolean sendNotifications,
39
+			final SecurityContext securityContext, final String auditEventId, final Container container) {
40
+		this.itemUid = uid;
41
+		this.vevent = vevent;
42
+		this.securityContext = securityContext;
43
+		this.container = container;
44
+		this.sendNotifications = sendNotifications;
45
+		this.auditEventId = auditEventId;
46
+	}
47
+
35 48
 	public VEventMessage copy() {
36 49
 		VEventMessage copy = new VEventMessage();
37 50
 		copy.itemUid = this.itemUid;
... ...
@@ -33,5 +33,7 @@ Require-Bundle: org.junit,
33 33
  net.bluemind.calendar.api,
34 34
  net.bluemind.tag.hooks;bundle-version="3.1.0",
35 35
  net.bluemind.externaluser.service;bundle-version="3.1.0",
36
- net.bluemind.externaluser.api
36
+ net.bluemind.externaluser.api,
37
+ net.bluemind.backend.cyrus,
38
+ net.bluemind.resource.service
37 39
 
... ...
@@ -3,4 +3,7 @@
3 3
  },
4 4
  { 
5 5
     "name":"bluemind/elasticsearch-tests" 
6
+ },
7
+ {
8
+    "name":"bluemind/imap-role"
6 9
 }]
7 10
new file mode 100644
... ...
@@ -0,0 +1,450 @@
1
+/* BEGIN LICENSE
2
+  * Copyright © Blue Mind SAS, 2012-2019
3
+  *
4
+  * This file is part of BlueMind. BlueMind is a messaging and collaborative
5
+  * solution.
6
+  *
7
+  * This program is free software; you can redistribute it and/or modify
8
+  * it under the terms of either the GNU Affero General Public License as
9
+  * published by the Free Software Foundation (version 3 of the License).
10
+  *
11
+  * This program is distributed in the hope that it will be useful,
12
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
+  *
15
+  * See LICENSE.txt
16
+  * END LICENSE
17
+  */
18
+package net.bluemind.calendar.service.internal;
19
+
20
+import static org.junit.Assert.assertNotNull;
21
+
22
+import java.sql.SQLException;
23
+import java.util.ArrayList;
24
+import java.util.Arrays;
25
+import java.util.Collections;
26
+import java.util.HashMap;
27
+import java.util.HashSet;
28
+import java.util.List;
29
+import java.util.Map;
30
+import java.util.UUID;
31
+
32
+import org.joda.time.DateTime;
33
+import org.joda.time.DateTimeZone;
34
+import org.junit.Assert;
35
+import org.junit.Before;
36
+import org.junit.Test;
37
+import org.vertx.java.core.AsyncResult;
38
+import org.vertx.java.core.Handler;
39
+
40
+import com.google.common.collect.Lists;
41
+import com.google.common.util.concurrent.SettableFuture;
42
+
43
+import net.bluemind.addressbook.api.VCard;
44
+import net.bluemind.addressbook.api.VCard.Identification.FormatedName;
45
+import net.bluemind.addressbook.api.VCard.Identification.Name;
46
+import net.bluemind.backend.cyrus.CyrusAdmins;
47
+import net.bluemind.backend.cyrus.CyrusService;
48
+import net.bluemind.calendar.api.CalendarContainerType;
49
+import net.bluemind.calendar.api.VEvent;
50
+import net.bluemind.calendar.api.VEventSeries;
51
+import net.bluemind.calendar.hook.internal.VEventMessage;
52
+import net.bluemind.config.InstallationId;
53
+import net.bluemind.core.api.Email;
54
+import net.bluemind.core.api.date.BmDateTime;
55
+import net.bluemind.core.api.date.BmDateTime.Precision;
56
+import net.bluemind.core.api.date.BmDateTimeWrapper;
57
+import net.bluemind.core.api.fault.ServerFault;
58
+import net.bluemind.core.container.model.Container;
59
+import net.bluemind.core.container.model.ItemValue;
60
+import net.bluemind.core.container.persistance.ContainerStore;
61
+import net.bluemind.core.context.SecurityContext;
62
+import net.bluemind.core.jdbc.JdbcTestHelper;
63
+import net.bluemind.core.rest.ServerSideServiceProvider;
64
+import net.bluemind.core.sessions.Sessions;
65
+import net.bluemind.core.tests.BmTestContext;
66
+import net.bluemind.directory.api.BaseDirEntry;
67
+import net.bluemind.domain.api.Domain;
68
+import net.bluemind.icalendar.api.ICalendarElement.Attendee;
69
+import net.bluemind.icalendar.api.ICalendarElement.CUType;
70
+import net.bluemind.lib.vertx.VertxPlatform;
71
+import net.bluemind.mailbox.api.Mailbox.Routing;
72
+import net.bluemind.pool.impl.BmConfIni;
73
+import net.bluemind.resource.api.IResources;
74
+import net.bluemind.resource.api.ResourceDescriptor;
75
+import net.bluemind.resource.api.ResourceDescriptor.PropertyValue;
76
+import net.bluemind.resource.api.ResourceReservationMode;
77
+import net.bluemind.resource.api.type.IResourceTypes;
78
+import net.bluemind.resource.api.type.ResourceTypeDescriptor;
79
+import net.bluemind.resource.api.type.ResourceTypeDescriptor.Property;
80
+import net.bluemind.server.api.IServer;
81
+import net.bluemind.server.api.Server;
82
+import net.bluemind.tag.api.TagRef;
83
+import net.bluemind.tests.defaultdata.PopulateHelper;
84
+import net.bluemind.user.api.User;
85
+import net.bluemind.user.persistance.UserSubscriptionStore;
86
+import net.bluemind.user.service.internal.ContainerUserStoreService;
87
+
88
+public class VEventSeriesSanitizerTests {
89
+	private static final String USER_UID_AND_LOGIN = "u1";
90
+	private static final String TEMPLATE = "Hello! I am a template mate! ${Organizer} invites you to this wonderful event with the property ${MyCustomPropOne} and also ${MyCustomPropTwo} and the even better ${MyCustomPropThree} !!! How lucky you!\nThis entire ${line} should be removed since it contains ${unknown} variables.\nThis line should be kept.";
91
+	private static final String TRANSFORMED_TEMPLATE = ResourceTemplateHandler.separator()
92
+			+ "FR Hello! I am a template mate! John Doe invites you to this wonderful event with the property My Custom Prop One Value and also My Custom Prop Two Value and the even better My Custom Prop Three Value !!! How lucky you!\nThis line should be kept.";
93
+	private String domainUid;
94
+	private ItemValue<Server> dataLocation;
95
+	private ContainerStore containerHome;
96
+	private ContainerUserStoreService userStoreService;
97
+	private User user;
98
+	private ServerSideServiceProvider provider;
99
+
100
+	@SuppressWarnings("deprecation")
101
+	@Before
102
+	public void before() throws Exception {
103
+		JdbcTestHelper.getInstance().beforeTest();
104
+		JdbcTestHelper.getInstance().getDbSchemaService().initialize();
105
+
106
+		final SettableFuture<Void> future = SettableFuture.<Void>create();
107
+		Handler<AsyncResult<Void>> done = new Handler<AsyncResult<Void>>() {
108
+
109
+			@Override
110
+			public void handle(AsyncResult<Void> event) {
111
+				future.set(null);
112
+			}
113
+		};
114
+		VertxPlatform.spawnVerticles(done);
115
+		future.get();
116
+
117
+		this.domainUid = "test.lan";
118
+
119
+		this.provider = ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM);
120
+
121
+		Server imapServer = new Server();
122
+		imapServer.ip = new BmConfIni().get("imap-role");
123
+		imapServer.tags = Lists.newArrayList("mail/imap");
124
+
125
+		PopulateHelper.initGlobalVirt(imapServer);
126
+		this.dataLocation = this.provider.instance(IServer.class, InstallationId.getIdentifier())
127
+				.getComplete(imapServer.ip);
128
+
129
+		this.containerHome = new ContainerStore(JdbcTestHelper.getInstance().getDataSource(), SecurityContext.SYSTEM);
130
+		this.initDomain(dataLocation, imapServer);
131
+
132
+		this.createCyrusPartition(imapServer, this.domainUid);
133
+	}
134
+
135
+	private void createCyrusPartition(final Server imapServer, final String domainUid) {
136
+		final CyrusService cyrusService = new CyrusService(imapServer.ip);
137
+		cyrusService.createPartition(domainUid);
138
+		cyrusService.refreshPartitions(Arrays.asList(domainUid));
139
+		new CyrusAdmins(
140
+				ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM).instance(IServer.class, "default"),
141
+				imapServer.ip).write();
142
+		cyrusService.reload();
143
+	}
144
+
145
+	/**
146
+	 * Test {@link ResourceDescriptionAdapterHook#onEventCreated(VEventMessage)} :
147
+	 * create an event with a resource having a template.
148
+	 */
149
+	@Test
150
+	public void onEventCreated() {
151
+		// build the event and call ResourceDescriptionAdapterHook.onEventCreated
152
+		final String description = "2 individuals attendees and 1 resource attendee having a template";
153
+		final VEventMessage vEventMessage = this.eventCreation(description, true);
154
+
155
+		// check the result - the processed template should have been added
156
+		Assert.assertNotNull(vEventMessage.vevent);
157
+		final List<VEvent> vEvents = vEventMessage.vevent.flatten();
158
+		Assert.assertNotNull(vEvents);
159
+		final String expectedResult = description + TRANSFORMED_TEMPLATE;
160
+		this.checkDescription(vEvents, expectedResult);
161
+	}
162
+
163
+	private VEventMessage eventCreation(final String description, final boolean withResource) {
164
+		// build event
165
+		final VEventMessage vEventMessage = this.buildEvent(description, withResource);
166
+
167
+		// call sanitizer
168
+		final Map<String, String> params = new HashMap<>(2);
169
+		params.put("owner", vEventMessage.container.owner);
170
+		params.put("domainUid", this.domainUid);
171
+		new VEventSeriesSanitizer(new BmTestContext(Sessions.get().getIfPresent(user.login)))
172
+				.create(vEventMessage.vevent, params);
173
+
174
+		return vEventMessage;
175
+	}
176
+
177
+	/**
178
+	 * Test {@link ResourceDescriptionAdapterHook#onEventUpdated(VEventMessage)} :
179
+	 * delete a resource having a template.
180
+	 */
181
+	@Test
182
+	public void onResourceDeleted() {
183
+		// first, create an event with a resource
184
+		final String oldDescription = "2 individuals attendees and 1 resource attendee having a template";
185
+		final VEventMessage oldEventMessage = this.eventCreation(oldDescription, true);
186
+
187
+		// build an event without a resource
188
+		final String description = "delete 1 resource attendee having an already transformed template in the description";
189
+		final VEventMessage vEventMessage = this.buildEvent(description + TRANSFORMED_TEMPLATE, false);
190
+		vEventMessage.oldEvent = oldEventMessage.vevent;
191
+
192
+		// execute the code
193
+		final Map<String, String> params = new HashMap<>(2);
194
+		params.put("owner", vEventMessage.container.owner);
195
+		params.put("domainUid", this.domainUid);
196
+		new VEventSeriesSanitizer(new BmTestContext(Sessions.get().getIfPresent(user.login)))
197
+				.update(vEventMessage.oldEvent, vEventMessage.vevent, params);
198
+
199
+		// check the result - the processed template should have been removed
200
+		Assert.assertNotNull(vEventMessage.vevent);
201
+		final List<VEvent> vEvents = vEventMessage.vevent.flatten();
202
+		Assert.assertNotNull(vEvents);
203
+		final String expectedResult = description;
204
+		this.checkDescription(vEvents, expectedResult);
205
+	}
206
+
207
+	/**
208
+	 * Test {@link ResourceDescriptionAdapterHook#onEventUpdated(VEventMessage)} :
209
+	 * add a resource having a template.
210
+	 */
211
+	@Test
212
+	public void onResourceAdded() {
213
+		// first, create an event without resource
214
+		final String oldDescription = "2 individuals attendees";
215
+		final VEventMessage oldEventMessage = this.eventCreation(oldDescription, false);
216
+
217
+		// build event with resource
218
+		final String description = "add 1 resource attendee having a template";
219
+		final VEventMessage vEventMessage = this.buildEvent(description, true);
220
+		vEventMessage.oldEvent = oldEventMessage.vevent;
221
+
222
+		// execute the code
223
+		final Map<String, String> params = new HashMap<>(2);
224
+		params.put("owner", vEventMessage.container.owner);
225
+		params.put("domainUid", this.domainUid);
226
+		new VEventSeriesSanitizer(new BmTestContext(Sessions.get().getIfPresent(user.login)))
227
+				.update(vEventMessage.oldEvent, vEventMessage.vevent, params);
228
+
229
+		// check the result - the processed template should have been added
230
+		Assert.assertNotNull(vEventMessage.vevent);
231
+		final List<VEvent> vEvents = vEventMessage.vevent.flatten();
232
+		Assert.assertNotNull(vEvents);
233
+		final String expectedResult = description + TRANSFORMED_TEMPLATE;
234
+		this.checkDescription(vEvents, expectedResult);
235
+	}
236
+
237
+	private void checkDescription(final List<VEvent> vEvents, final String expectedResult) {
238
+		vEvents.forEach(vEvent -> {
239
+			Assert.assertNotNull(vEvent.description);
240
+			Assert.assertEquals(expectedResult, vEvent.description);
241
+		});
242
+	}
243
+
244
+	private VEventMessage buildEvent(final String description, final boolean withResource) {
245
+		final String subject = "onResourceCreated";
246
+		final List<Attendee> attendees = new ArrayList<>(3);
247
+
248
+		final Attendee toto = new Attendee();
249
+		toto.commonName = "Toto Matic";
250
+		toto.cutype = CUType.Individual;
251
+		toto.mailto = "toto@" + this.domainUid;
252
+		attendees.add(toto);
253
+
254
+		final Attendee georges = new Attendee();
255
+		georges.commonName = "Georges Abitbol";
256
+		georges.cutype = CUType.Individual;
257
+		georges.mailto = "georges@" + this.domainUid;
258
+		attendees.add(georges);
259
+
260
+		if (withResource) {
261
+			final Attendee visio = this.buildAndPersistResource();
262
+			attendees.add(visio);
263
+		}
264
+
265
+		final VEventMessage vEventMessage = this.buildEvent(subject, description, attendees);
266
+
267
+		return vEventMessage;
268
+	}
269
+
270
+	@SuppressWarnings("serial")
271
+	private Attendee buildAndPersistResource() {
272
+		final Attendee visio = new Attendee();
273
+		visio.commonName = "Visio-conference";
274
+		visio.cutype = CUType.Resource;
275
+		final String resourceId = "visioId";
276
+		visio.mailto = resourceId + "@" + this.domainUid;
277
+		visio.dir = "path/to/my/resource/" + resourceId;
278
+		final String resourceTypeId = "visioTypeId";
279
+		final String template = TEMPLATE;
280
+		this.createResourceTypeWithTemplate(resourceTypeId, visio.commonName, new HashMap<String, String>() {
281
+			{
282
+				put("customProp1", "MyCustomPropOne");
283
+				put("customProp2", "MyCustomPropTwo");
284
+				put("customProp3", "MyCustomPropThree");
285
+			}
286
+		}, template);
287
+
288
+		this.createResource(resourceId, resourceTypeId, visio.commonName, new HashMap<String, String>() {
289
+			{
290
+				put("customProp1", "My Custom Prop One Value");
291
+				put("customProp2", "My Custom Prop Two Value");
292
+				put("customProp3", "My Custom Prop Three Value");
293
+			}
294
+		});
295
+		return visio;
296
+	}
297
+
298
+	private void initDomain(ItemValue<Server> dataLocation, Server... servers) throws Exception {
299
+		ItemValue<Domain> domain = PopulateHelper.createTestDomain(domainUid, servers);
300
+		Container userContainer = containerHome.get(domainUid);
301
+		this.userStoreService = new ContainerUserStoreService(new BmTestContext(SecurityContext.SYSTEM), userContainer,
302
+				domain);
303
+		Container mboxContainer = containerHome.get(domainUid);
304
+		assertNotNull(mboxContainer);
305
+		ItemValue<User> user1Item = createTestUser(dataLocation, USER_UID_AND_LOGIN);
306
+		this.user = user1Item.value;
307
+	}
308
+
309
+	@SuppressWarnings("deprecation")
310
+	private ItemValue<User> createTestUser(ItemValue<Server> dataLocation, String login)
311
+			throws ServerFault, SQLException {
312
+		ItemValue<User> user = defaultUser(dataLocation, login, login);
313
+		userStoreService.create(user.uid, login, user.value);
314
+		SecurityContext securityContext = new SecurityContext(login, login, new ArrayList<String>(),
315
+				new ArrayList<String>(), domainUid);
316
+		createTestContainer(securityContext, CalendarContainerType.TYPE, user.value.login,
317
+				CalendarContainerType.TYPE + ":Default:" + user.uid, user.uid);
318
+		Sessions.get().put(login, securityContext);
319
+		return user;
320
+	}
321
+
322
+	@SuppressWarnings("deprecation")
323
+	private void createTestContainer(SecurityContext context, String type, String login, String name, String owner)
324
+			throws SQLException {
325
+		ContainerStore containerHome = new ContainerStore(JdbcTestHelper.getInstance().getDataSource(), context);
326
+		Container container = Container.create(name, type, name, owner, this.domainUid, true);
327
+		container = containerHome.create(container);
328
+		Container dom = containerHome.get(domainUid);
329
+		UserSubscriptionStore userSubscriptionStore = new UserSubscriptionStore(SecurityContext.SYSTEM,
330
+				JdbcTestHelper.getInstance().getDataSource(), dom);
331
+		userSubscriptionStore.subscribe(context.getSubject(), container);
332
+	}
333
+
334
+	private ItemValue<User> defaultUser(ItemValue<Server> dataLocation, String uid, String login) {
335
+		User user = new User();
336
+		user.login = login;
337
+		Email em = new Email();
338
+		em.address = login + "@test.lan";
339
+		em.isDefault = true;
340
+		em.allAliases = false;
341
+		user.emails = Arrays.asList(em);
342
+		user.password = "password";
343
+		user.routing = Routing.internal;
344
+		user.dataLocation = dataLocation.uid;
345
+
346
+		VCard card = new VCard();
347
+		card.identification.name = Name.create("Doe", "John", null, null, null, null);
348
+		card.identification.formatedName = FormatedName.create(login);
349
+		user.contactInfos = card;
350
+		return ItemValue.create(uid, user);
351
+	}
352
+
353
+	@SuppressWarnings("deprecation")
354
+	private VEventMessage buildEvent(final String summary, final String description, final List<Attendee> attendees) {
355
+		final VEventMessage veventMessage = new VEventMessage();
356
+
357
+		final ItemValue<VEventSeries> event = defaultVEvent(summary, description);
358
+		event.value.main.attendees = attendees;
359
+
360
+		veventMessage.itemUid = event.uid;
361
+		veventMessage.vevent = event.value;
362
+		veventMessage.oldEvent = null;
363
+		veventMessage.securityContext = SecurityContext.SYSTEM;
364
+		veventMessage.sendNotifications = true;
365
+		try {
366
+			veventMessage.container = new ContainerStore(JdbcTestHelper.getInstance().getDataSource(),
367
+					SecurityContext.SYSTEM).get(CalendarContainerType.TYPE + ":Default:" + user.login);
368
+			Assert.assertNotNull(veventMessage.container);
369
+			veventMessage.container.domainUid = this.domainUid;
370
+		} catch (SQLException e) {
371
+			e.printStackTrace();
372
+			Assert.fail(e.getMessage());
373
+		}
374
+
375
+		return veventMessage;
376
+	}
377
+
378
+	private ItemValue<VEventSeries> defaultVEvent(final String summary, final String description) {
379
+		final VEvent event = new VEvent();
380
+		final DateTimeZone tz = DateTimeZone.forID("Europe/Paris");
381
+
382
+		final long now = System.currentTimeMillis();
383
+		final long start = now + (1000 * 60 * 60);
384
+		DateTime temp = new DateTime(start, tz);
385
+		event.dtstart = BmDateTimeWrapper.create(temp, Precision.DateTime);
386
+		temp = new DateTime(start + (1000 * 60 * 60), tz);
387
+		event.dtend = BmDateTimeWrapper.create(temp, Precision.DateTime);
388
+		event.summary = summary;
389
+		event.location = "Toulouse";
390
+		event.description = description;
391
+		event.priority = 1;
392
+		event.organizer = new VEvent.Organizer("John Doe", this.user.defaultEmailAddress());
393
+		event.organizer.dir = "bm://" + this.domainUid + "/" + BaseDirEntry.Kind.USER.name() + "/" + this.user.login;
394
+		event.attendees = new ArrayList<>();
395
+		event.categories = new ArrayList<TagRef>(0);
396
+
397
+		event.rdate = new HashSet<BmDateTime>();
398
+		event.rdate.add(BmDateTimeWrapper.create(temp, Precision.Date));
399
+
400
+		final VEventSeries series = new VEventSeries();
401
+		series.main = event;
402
+
403
+		return ItemValue.create(UUID.randomUUID().toString(), series);
404
+	}
405
+
406
+	private void createResourceTypeWithTemplate(final String resourceTypeId, final String label,
407
+			final Map<String, String> propsLabels, String template) {
408
+		final ResourceTypeDescriptor resourceTypeDescriptor = new ResourceTypeDescriptor();
409
+		resourceTypeDescriptor.label = label;
410
+		if (propsLabels != null) {
411
+			resourceTypeDescriptor.properties = new ArrayList<>(propsLabels.size());
412
+			propsLabels.entrySet().forEach(entry -> {
413
+				final Property p = new Property();
414
+				p.id = entry.getKey();
415
+				p.label = "en::" + entry.getValue() + "\nfr::" + entry.getValue() + "Fr";
416
+				p.type = Property.Type.String;
417
+				resourceTypeDescriptor.properties.add(p);
418
+			});
419
+		}
420
+		resourceTypeDescriptor.templates.put("fr", "FR " + template);
421
+		resourceTypeDescriptor.templates.put("en", "EN " + template);
422
+
423
+		this.provider.instance(IResourceTypes.class, domainUid).create(resourceTypeId, resourceTypeDescriptor);
424
+
425
+	}
426
+
427
+	private void createResource(final String resourceId, final String resourceTypeId, final String label,
428
+			final Map<String, String> propsValues) {
429
+		final ResourceDescriptor resourceDescriptor = new ResourceDescriptor();
430
+		resourceDescriptor.typeIdentifier = resourceTypeId;
431
+		resourceDescriptor.label = label;
432
+		resourceDescriptor.description = "What a mighty description!";
433
+		resourceDescriptor.reservationMode = ResourceReservationMode.OWNER_MANAGED;
434
+		resourceDescriptor.dataLocation = this.dataLocation.uid;
435
+		resourceDescriptor.emails = Collections
436
+				.singletonList(Email.create(resourceId.toLowerCase() + "@test.lan", true));
437
+		if (propsValues != null) {
438
+			resourceDescriptor.properties = new ArrayList<>(propsValues.size());
439
+			propsValues.entrySet().forEach(entry -> {
440
+				final PropertyValue p = new PropertyValue();
441
+				p.propertyId = entry.getKey();
442
+				p.value = entry.getValue();
443
+				resourceDescriptor.properties.add(p);
444
+			});
445
+		}
446
+
447
+		this.provider.instance(IResources.class, domainUid).create(resourceId, resourceDescriptor);
448
+	}
449
+
450
+}
... ...
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
22 22
 import static org.junit.Assert.assertFalse;
23 23
 
24 24
 import java.util.ArrayList;
25
+import java.util.Arrays;
25 26
 import java.util.HashMap;
26 27
 import java.util.Map;
27 28
 
... ...
@@ -37,6 +38,8 @@ import com.google.common.collect.ImmutableList;
37 38
 import com.google.common.collect.Lists;
38 39
 import com.google.common.util.concurrent.SettableFuture;
39 40
 
41
+import net.bluemind.backend.cyrus.CyrusAdmins;
42
+import net.bluemind.backend.cyrus.CyrusService;
40 43
 import net.bluemind.calendar.api.CalendarContainerType;
41 44
 import net.bluemind.calendar.api.VEvent;
42 45
 import net.bluemind.calendar.api.VEventOccurrence;
... ...
@@ -51,9 +54,12 @@ import net.bluemind.core.context.SecurityContext;
51 54
 import net.bluemind.core.elasticsearch.ElasticsearchTestHelper;
52 55
 import net.bluemind.core.jdbc.JdbcActivator;
53 56
 import net.bluemind.core.jdbc.JdbcTestHelper;
57
+import net.bluemind.core.rest.ServerSideServiceProvider;
54 58
 import net.bluemind.core.task.service.NullTaskMonitor;
55 59
 import net.bluemind.core.tests.BmTestContext;
56 60
 import net.bluemind.lib.vertx.VertxPlatform;
61
+import net.bluemind.pool.impl.BmConfIni;
62
+import net.bluemind.server.api.IServer;
57 63
 import net.bluemind.server.api.Server;
58 64
 import net.bluemind.tag.api.ITags;
59 65
 import net.bluemind.tag.api.Tag;
... ...
@@ -92,10 +98,18 @@ public class CalendarRepairSupportTests {
92 98
 		Server esServer = new Server();
93 99
 		esServer.ip = ElasticsearchTestHelper.getInstance().getHost();
94 100
 		esServer.tags = Lists.newArrayList("bm/es");
95
-		PopulateHelper.initGlobalVirt(esServer);
96 101
 
97
-		domainUid = "bm.lan";
98
-		PopulateHelper.createTestDomain(domainUid);
102
+		Server imapServer = new Server();
103
+		imapServer.ip = new BmConfIni().get("imap-role");
104
+		imapServer.tags = Lists.newArrayList("mail/imap");
105
+
106
+		PopulateHelper.initGlobalVirt(esServer, imapServer);
107
+
108
+		domainUid = "test.lan";
109
+		PopulateHelper.createTestDomain(domainUid, esServer, imapServer);
110
+
111
+		this.createCyrusPartition(imapServer, this.domainUid);
112
+
99 113
 		user1 = PopulateHelper.addUser("test1", domainUid);
100 114
 		user2 = PopulateHelper.addUser("test2", domainUid);
101 115
 
... ...
@@ -116,6 +130,16 @@ public class CalendarRepairSupportTests {
116 130
 		css.setSettings(settings);
117 131
 	}
118 132
 
133
+	private void createCyrusPartition(final Server imapServer, final String domainUid) {
134
+		final CyrusService cyrusService = new CyrusService(imapServer.ip);
135
+		cyrusService.createPartition(domainUid);
136
+		cyrusService.refreshPartitions(Arrays.asList(domainUid));
137
+		new CyrusAdmins(
138
+				ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM).instance(IServer.class, "default"),
139
+				imapServer.ip).write();
140
+		cyrusService.reload();
141
+	}
142
+
119 143
 	@After
120 144
 	public void after() throws Exception {
121 145
 		JdbcTestHelper.getInstance().afterTest();
... ...
@@ -38,6 +38,8 @@ import com.google.common.util.concurrent.SettableFuture;
38 38
 import net.bluemind.addressbook.api.VCard;
39 39
 import net.bluemind.addressbook.api.VCard.Identification.Name;
40 40
 import net.bluemind.addressbook.domainbook.IDomainAddressBook;
41
+import net.bluemind.backend.cyrus.CyrusAdmins;
42
+import net.bluemind.backend.cyrus.CyrusService;
41 43
 import net.bluemind.calendar.api.CalendarContainerType;
42 44
 import net.bluemind.calendar.api.CalendarLookupResponse;
43 45
 import net.bluemind.calendar.api.ICalendarAutocomplete;
... ...
@@ -53,15 +55,17 @@ import net.bluemind.core.context.SecurityContext;
53 55
 import net.bluemind.core.elasticsearch.ElasticsearchTestHelper;
54 56
 import net.bluemind.core.jdbc.JdbcTestHelper;
55 57
 import net.bluemind.core.rest.BmContext;
58
+import net.bluemind.core.rest.ServerSideServiceProvider;
56 59
 import net.bluemind.core.sessions.Sessions;
57 60
 import net.bluemind.core.tests.BmTestContext;
58
-import net.bluemind.externaluser.api.ExternalUser;
59 61
 import net.bluemind.group.api.Group;
60 62
 import net.bluemind.group.api.IGroup;
61 63
 import net.bluemind.group.api.Member;
62 64
 import net.bluemind.lib.vertx.VertxPlatform;
63 65
 import net.bluemind.mailbox.api.Mailbox.Routing;
66
+import net.bluemind.pool.impl.BmConfIni;
64 67
 import net.bluemind.role.api.BasicRoles;
68
+import net.bluemind.server.api.IServer;
65 69
 import net.bluemind.server.api.Server;
66 70
 import net.bluemind.tests.defaultdata.PopulateHelper;
67 71
 import net.bluemind.user.api.IUser;
... ...
@@ -69,11 +73,13 @@ import net.bluemind.user.api.User;
69 73
 import net.bluemind.user.persistance.UserSubscriptionStore;
70 74
 
71 75
 public class CalendarAutocompleteServiceTests {
76
+	private static final String DOMAIN = "test.lan";
72 77
 	private BmContext testContext;
73 78
 	protected SecurityContext defaultSecurityContext;
74 79
 	private ContainerStore containerStore;
75
-	private AclStore aclStore;
76 80
 	private SecurityContext adminSecurityContext;
81
+	private Server imapServer;
82
+	private AclStore aclStore;
77 83
 
78 84
 	@Before
79 85
 	public void before() throws Exception {
... ...
@@ -96,26 +102,33 @@ public class CalendarAutocompleteServiceTests {
96 102
 		esServer.ip = ElasticsearchTestHelper.getInstance().getHost();
97 103
 		esServer.tags = Lists.newArrayList("bm/es");
98 104
 
99
-		PopulateHelper.initGlobalVirt(esServer);
100
-		PopulateHelper.addDomain("bm.lan");
101
-		PopulateHelper.addUser("test", "bm.lan");
105
+		this.imapServer = new Server();
106
+		imapServer.ip = new BmConfIni().get("imap-role");
107
+		imapServer.tags = Lists.newArrayList("mail/imap");
108
+
109
+		PopulateHelper.initGlobalVirt(esServer, imapServer);
110
+		PopulateHelper.createTestDomain(DOMAIN, esServer, imapServer);
111
+
112
+		this.createCyrusPartition(imapServer, DOMAIN);
113
+
114
+		PopulateHelper.addUser("test", DOMAIN);
102 115
 		defaultSecurityContext = new SecurityContext("testUser", "test", Arrays.<String>asList(),
103
-				Arrays.<String>asList(), "bm.lan");
116
+				Arrays.<String>asList(), DOMAIN);
104 117
 
105 118
 		Sessions.get().put(defaultSecurityContext.getSessionId(), defaultSecurityContext);
106 119
 
107 120
 		adminSecurityContext = new SecurityContext("testAdmin", "testAdmin", Arrays.<String>asList(),
108
-				Arrays.<String>asList(BasicRoles.ROLE_ADMIN), "bm.lan");
121
+				Arrays.<String>asList(BasicRoles.ROLE_ADMIN), DOMAIN);
109 122
 
110 123
 		Sessions.get().put(adminSecurityContext.getSessionId(), adminSecurityContext);
111 124
 
112 125
 		containerStore = new ContainerStore(JdbcTestHelper.getInstance().getDataSource(), defaultSecurityContext);
113 126
 
114
-		aclStore = new AclStore(new BmTestContext(SecurityContext.SYSTEM),
127
+		this.aclStore = new AclStore(new BmTestContext(SecurityContext.SYSTEM),
115 128
 				JdbcTestHelper.getInstance().getDataSource());
116 129
 
117 130
 		Container container = Container.create("addressbook_testUser", "addressbook", "Contacts",
118
-				defaultSecurityContext.getSubject(), "bm.lan", true);
131
+				defaultSecurityContext.getSubject(), DOMAIN, true);
119 132
 		container = containerStore.create(container);
120 133
 		assertNotNull(container);
121 134
 
... ...
@@ -123,21 +136,31 @@ public class CalendarAutocompleteServiceTests {
123 136
 				Arrays.asList(AccessControlEntry.create(defaultSecurityContext.getSubject(), Verb.All)));
124 137
 
125 138
 		UserSubscriptionStore userSubscriptionStore = new UserSubscriptionStore(SecurityContext.SYSTEM,
126
-				JdbcTestHelper.getInstance().getDataSource(), containerStore.get("bm.lan"));
139
+				JdbcTestHelper.getInstance().getDataSource(), containerStore.get(DOMAIN));
127 140
 
128 141
 		userSubscriptionStore.subscribe(defaultSecurityContext.getSubject(), container);
129
-
142
+		
130 143
 		testContext = new BmTestContext(SecurityContext.SYSTEM);
131 144
 	}
132 145
 
146
+	private void createCyrusPartition(final Server imapServer, final String domainUid) {
147
+		final CyrusService cyrusService = new CyrusService(imapServer.ip);
148
+		cyrusService.createPartition(domainUid);
149
+		cyrusService.refreshPartitions(Arrays.asList(domainUid));
150
+		new CyrusAdmins(
151
+				ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM).instance(IServer.class, "default"),
152
+				imapServer.ip).write();
153
+		cyrusService.reload();
154
+	}
155
+
133 156
 	protected Container createTestContainer(String uid, String name, Verb verb, boolean isDefault) throws Exception {
134 157
 
135 158
 		Container container = Container.create(uid, CalendarContainerType.TYPE, name,
136
-				defaultSecurityContext.getSubject(), "bm.lan", isDefault);
159
+				defaultSecurityContext.getSubject(), DOMAIN, isDefault);
137 160
 		container = containerStore.create(container);
138 161
 		assertNotNull(container);
139 162
 
140
-		aclStore.store(container, Arrays.asList(AccessControlEntry.create(defaultSecurityContext.getSubject(), verb)));
163
+		this.aclStore.store(container, Arrays.asList(AccessControlEntry.create(defaultSecurityContext.getSubject(), verb)));
141 164
 
142 165
 		return container;
143 166
 	}
... ...
@@ -150,7 +173,7 @@ public class CalendarAutocompleteServiceTests {
150 173
 
151 174
 	protected void createTestUser(String uid, String firstname, String lastname, Verb verb)
152 175
 			throws SQLException, ServerFault {
153
-		IUser users = testContext.provider().instance(IUser.class, "bm.lan");
176
+		IUser users = testContext.provider().instance(IUser.class, DOMAIN);
154 177
 
155 178
 		String f = java.text.Normalizer.normalize(firstname, java.text.Normalizer.Form.NFD)
156 179
 				.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
... ...
@@ -164,10 +187,8 @@ public class CalendarAutocompleteServiceTests {
164 187
 		aclStore.store(cal, Arrays.asList(AccessControlEntry.create(defaultSecurityContext.getSubject(), verb)));
165 188
 	}
166 189
 
167
-	protected String createTestExternalUser(String name,
168
-			String email) {
169
-		ExternalUser eu = new ExternalUser();
170
-		return PopulateHelper.addExternalUser("bm.lan", email, name);
190
+	protected String createTestExternalUser(String name, String email) {
191
+		return PopulateHelper.addExternalUser(DOMAIN, email, name);
171 192
 	}
172 193
 
173 194
 	protected void createTestGroup(String uid, String name, String... membersUid) throws SQLException, ServerFault {
... ...
@@ -181,11 +202,11 @@ public class CalendarAutocompleteServiceTests {
181 202
 
182 203
 	protected void createTestGroup(String uid, String name, boolean hidden, boolean hiddenMembers, Member... members)
183 204
 			throws SQLException, ServerFault {
184
-		IGroup groups = testContext.provider().instance(IGroup.class, "bm.lan");
205
+		IGroup groups = testContext.provider().instance(IGroup.class, DOMAIN);
185 206
 		Group g = new Group();
186 207
 		g.name = name;
187 208
 		// server imap uid
188
-		g.dataLocation = PopulateHelper.FAKE_CYRUS_IP;
209
+		g.dataLocation = this.imapServer.ip;
189 210
 		g.hidden = hidden;
190 211
 		g.hiddenMembers = hiddenMembers;
191 212
 		groups.create(uid, g);
... ...
@@ -197,7 +218,7 @@ public class CalendarAutocompleteServiceTests {
197 218
 		net.bluemind.user.api.User user = new User();
198 219
 		user.login = login;
199 220
 		Email em = new Email();
200
-		em.address = login + "@bm.lan";
221
+		em.address = login + "@" + DOMAIN;
201 222
 		em.isDefault = true;
202 223
 		em.allAliases = false;
203 224
 		user.emails = Arrays.asList(em);
... ...
@@ -321,7 +342,7 @@ public class CalendarAutocompleteServiceTests {
321 342
 
322 343
 		createTestGroup("g1", "David Gilmour all band", Member.user("u1"), Member.user("u2"), Member.user("u3"),
323 344
 				Member.group("g2"), Member.group("g3"), Member.group("g4"));
324
-		testContext.provider().instance(IDomainAddressBook.class, "bm.lan").sync();
345
+		testContext.provider().instance(IDomainAddressBook.class, DOMAIN).sync();
325 346
 
326 347
 		res = service.calendarLookup("david", Verb.Read);
327 348
 		assertEquals(3, res.size());
... ...
@@ -363,13 +384,10 @@ public class CalendarAutocompleteServiceTests {
363 384
 		createTestUser("user2", "Johnny", "B", Verb.Read);
364 385
 		String extUserUid = createTestExternalUser("ExtUserName", "ext@user.com");
365 386
 		String groupUid = "myGroup";
366
-		createTestGroup(groupUid, "zorg", false, false,
367
-				Member.user("user1"), Member.user("user2"),
387
+		createTestGroup(groupUid, "zorg", false, false, Member.user("user1"), Member.user("user2"),
368 388
 				Member.externalUser(extUserUid));
369 389
 
370
-		List<CalendarLookupResponse> res = service
371
-				.calendarLookup("zorg",
372
-				Verb.Invitation);
390
+		List<CalendarLookupResponse> res = service.calendarLookup("zorg", Verb.Invitation);
373 391
 		assertEquals(2, res.get(0).memberCount);
374 392
 	}
375 393
 
... ...
@@ -34,8 +34,13 @@ import org.vertx.java.core.Handler;
34 34
 import com.google.common.collect.Lists;
35 35
 import com.google.common.util.concurrent.SettableFuture;
36 36
 
37
+import net.bluemind.addressbook.api.VCard;
38
+import net.bluemind.addressbook.api.VCard.Identification.Name;
39
+import net.bluemind.backend.cyrus.CyrusAdmins;
40
+import net.bluemind.backend.cyrus.CyrusService;
37 41
 import net.bluemind.calendar.api.CalendarDescriptor;
38 42
 import net.bluemind.calendar.api.ICalendarsMgmt;
43
+import net.bluemind.core.api.Email;
39 44
 import net.bluemind.core.api.fault.ErrorCode;
40 45
 import net.bluemind.core.api.fault.ServerFault;
41 46
 import net.bluemind.core.container.persistance.ContainerStore;
... ...
@@ -49,9 +54,12 @@ import net.bluemind.core.tests.BmTestContext;
49 54
 import net.bluemind.directory.api.DirEntry;
50 55
 import net.bluemind.directory.api.IDirectory;
51 56
 import net.bluemind.lib.vertx.VertxPlatform;
57
+import net.bluemind.mailbox.api.Mailbox.Routing;
52 58
 import net.bluemind.pool.impl.BmConfIni;
59
+import net.bluemind.server.api.IServer;
53 60
 import net.bluemind.server.api.Server;
54 61
 import net.bluemind.tests.defaultdata.PopulateHelper;
62
+import net.bluemind.user.api.User;
55 63
 
56 64
 public class CalendarsMgmtTests {
57 65
 
... ...
@@ -71,14 +79,21 @@ public class CalendarsMgmtTests {
71 79
 		esServer.ip = ElasticsearchTestHelper.getInstance().getHost();
72 80
 		esServer.tags = Lists.newArrayList("bm/es");
73 81
 
74
-		PopulateHelper.initGlobalVirt(esServer);
82
+		Server imapServer = new Server();
83
+		imapServer.ip = new BmConfIni().get("imap-role");
84
+		imapServer.tags = Lists.newArrayList("mail/imap");
75 85
 
76
-		domainUid = "test" + System.currentTimeMillis() + ".lan";
86
+		PopulateHelper.initGlobalVirt(esServer, imapServer);
87
+
88
+		domainUid = "test.lan";
77 89
 
78 90
 		domainAdmin = BmTestContext.contextWithSession("testUser", "test", domainUid, SecurityContext.ROLE_ADMIN)
79 91
 				.getSecurityContext();
80 92
 
81
-		PopulateHelper.addDomain(domainUid);
93
+		PopulateHelper.createTestDomain(domainUid, esServer, imapServer);
94
+
95
+		this.createCyrusPartition(imapServer, domainUid);
96
+
82 97
 		PopulateHelper.domainAdmin(domainUid, domainAdmin.getSubject());
83 98
 		final SettableFuture<Void> future = SettableFuture.<Void>create();
84 99
 		Handler<AsyncResult<Void>> done = new Handler<AsyncResult<Void>>() {
... ...
@@ -102,6 +117,32 @@ public class CalendarsMgmtTests {
102 117
 		testContext = new BmTestContext(SecurityContext.SYSTEM);
103 118
 	}
104 119
 
120
+	private void createCyrusPartition(final Server imapServer, final String domainUid) {
121
+		final CyrusService cyrusService = new CyrusService(imapServer.ip);
122
+		cyrusService.createPartition(domainUid);
123
+		cyrusService.refreshPartitions(Arrays.asList(domainUid));
124
+		new CyrusAdmins(
125
+				ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM).instance(IServer.class, "default"),
126
+				imapServer.ip).write();
127
+		cyrusService.reload();
128
+	}
129
+
130
+	private User defaultUser(String login) {
131
+		User user = new User();
132
+		user.login = login;
133
+		Email em = new Email();
134
+		em.address = login + "@" + this.domainUid;
135
+		em.isDefault = true;
136
+		em.allAliases = false;
137
+		user.emails = Arrays.asList(em);
138
+		user.password = "password";
139
+		user.routing = Routing.none;
140
+		VCard card = new VCard();
141
+		card.identification.name = Name.create(login, login, null, null, null, null);
142
+		user.contactInfos = card;
143
+		return user;
144
+	}
145
+
105 146
 	@Test
106 147
 	public void testCreate_Domain() throws ServerFault, SQLException {
107 148
 		String calUid = "testdomab" + System.currentTimeMillis();
... ...
@@ -33,9 +33,12 @@ import org.junit.Test;
33 33
 import org.vertx.java.core.AsyncResult;
34 34
 import org.vertx.java.core.Handler;
35 35
 
36
+import com.google.common.collect.Lists;
36 37
 import com.google.common.util.concurrent.SettableFuture;
37 38
 
38 39
 import net.bluemind.calendar.api.FreebusyContainerType;
40
+import net.bluemind.backend.cyrus.CyrusAdmins;
41
+import net.bluemind.backend.cyrus.CyrusService;
39 42
 import net.bluemind.calendar.api.IFreebusyMgmt;
40 43
 import net.bluemind.core.api.fault.ServerFault;
41 44
 import net.bluemind.core.container.model.Container;
... ...
@@ -48,11 +51,15 @@ import net.bluemind.core.jdbc.JdbcTestHelper;
48 51
 import net.bluemind.core.rest.ServerSideServiceProvider;
49 52
 import net.bluemind.core.sessions.Sessions;
50 53
 import net.bluemind.lib.vertx.VertxPlatform;
54
+import net.bluemind.pool.impl.BmConfIni;
55
+import net.bluemind.server.api.IServer;
56
+import net.bluemind.server.api.Server;
51 57
 import net.bluemind.tests.defaultdata.PopulateHelper;
52 58
 import net.bluemind.user.persistance.UserSubscriptionStore;
53 59
 
54 60
 public class FreebusyMgmtTests {
55 61
 
62
+	private static final String DOMAIN = "test.lan";
56 63
 	protected SecurityContext defaultSecurityContext;
57 64
 	protected SecurityContext anotherSecurityContext;
58 65
 	protected Container container;
... ...
@@ -61,7 +68,6 @@ public class FreebusyMgmtTests {
61 68
 	public void before() throws Exception {
62 69
 		JdbcTestHelper.getInstance().beforeTest();
63 70
 		JdbcTestHelper.getInstance().getDbSchemaService().initialize();
64
-
65 71
 		final SettableFuture<Void> future = SettableFuture.<Void>create();
66 72
 		Handler<AsyncResult<Void>> done = new Handler<AsyncResult<Void>>() {
67 73
 
... ...
@@ -73,11 +79,18 @@ public class FreebusyMgmtTests {
73 79
 		VertxPlatform.spawnVerticles(done);
74 80
 		future.get();
75 81
 
76
-		PopulateHelper.initGlobalVirt();
82
+		Server imapServer = new Server();
83
+		imapServer.ip = new BmConfIni().get("imap-role");
84
+		imapServer.tags = Lists.newArrayList("mail/imap");
85
+
86
+		PopulateHelper.initGlobalVirt(imapServer);
87
+
88
+		PopulateHelper.createTestDomain(DOMAIN, imapServer);
89
+
90
+		this.createCyrusPartition(imapServer, DOMAIN);
77 91
 
78
-		PopulateHelper.addDomain("bm.lan");
79 92
 		defaultSecurityContext = new SecurityContext("testUser", "test", Arrays.<String>asList(),
80
-				Arrays.<String>asList(), "bm.lan");
93
+				Arrays.<String>asList(), DOMAIN);
81 94
 
82 95
 		Sessions.get().put(defaultSecurityContext.getSessionId(), defaultSecurityContext);
83 96
 
... ...
@@ -87,7 +100,7 @@ public class FreebusyMgmtTests {
87 100
 		AclStore aclStore = new AclStore(JdbcTestHelper.getInstance().getDataSource());
88 101
 
89 102
 		container = Container.create(UUID.randomUUID().toString(), FreebusyContainerType.TYPE, "fb container",
90
-				defaultSecurityContext.getSubject(), "bm.lan", true);
103
+				defaultSecurityContext.getSubject(), DOMAIN, true);
91 104
 		container = containerStore.create(container);
92 105
 		assertNotNull(container);
93 106
 
... ...
@@ -95,17 +108,27 @@ public class FreebusyMgmtTests {
95 108
 				Arrays.asList(AccessControlEntry.create(defaultSecurityContext.getSubject(), Verb.All)));
96 109
 
97 110
 		UserSubscriptionStore userSubscriptionStore = new UserSubscriptionStore(SecurityContext.SYSTEM,
98
-				JdbcTestHelper.getInstance().getDataSource(), containerStore.get("bm.lan"));
111
+				JdbcTestHelper.getInstance().getDataSource(), containerStore.get(DOMAIN));
99 112
 
100 113
 		userSubscriptionStore.subscribe(defaultSecurityContext.getSubject(), container);
101 114
 
102 115
 		anotherSecurityContext = new SecurityContext(UUID.randomUUID().toString(), "another", Arrays.<String>asList(),
103
-				Arrays.<String>asList(), "bm.lan");
116
+				Arrays.<String>asList(), "another.lan");
104 117
 
105 118
 		Sessions.get().put(anotherSecurityContext.getSessionId(), anotherSecurityContext);
106 119
 
107 120
 	}
108 121
 
122
+	private void createCyrusPartition(final Server imapServer, final String domainUid) {
123
+		final CyrusService cyrusService = new CyrusService(imapServer.ip);
124
+		cyrusService.createPartition(domainUid);
125
+		cyrusService.refreshPartitions(Arrays.asList(domainUid));
126
+		new CyrusAdmins(
127
+				ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM).instance(IServer.class, "default"),
128
+				imapServer.ip).write();
129
+		cyrusService.reload();
130
+	}
131
+
109 132
 	@After
110 133
 	public void after() throws Exception {
111 134
 		JdbcTestHelper.getInstance().afterTest();
... ...
@@ -36,6 +36,8 @@ import com.google.common.util.concurrent.SettableFuture;
36 36
 
37 37
 import net.bluemind.addressbook.api.VCard;
38 38
 import net.bluemind.addressbook.api.VCard.Identification.Name;
39
+import net.bluemind.backend.cyrus.CyrusAdmins;
40
+import net.bluemind.backend.cyrus.CyrusService;
39 41
 import net.bluemind.calendar.api.VEvent;
40 42
 import net.bluemind.calendar.api.VEventSeries;
41 43
 import net.bluemind.calendar.service.internal.VEventSanitizer;
... ...
@@ -46,6 +48,7 @@ import net.bluemind.core.api.fault.ServerFault;
46 48
 import net.bluemind.core.context.SecurityContext;
47 49
 import net.bluemind.core.elasticsearch.ElasticsearchTestHelper;
48 50
 import net.bluemind.core.jdbc.JdbcTestHelper;
51
+import net.bluemind.core.rest.ServerSideServiceProvider;
49 52
 import net.bluemind.core.tests.BmTestContext;
50 53
 import net.bluemind.group.api.Group;
51 54
 import net.bluemind.group.api.IGroup;
... ...
@@ -55,6 +58,8 @@ import net.bluemind.icalendar.api.ICalendarElement.Organizer;
55 58
 import net.bluemind.icalendar.api.ICalendarElement.ParticipationStatus;
56 59
 import net.bluemind.lib.vertx.VertxPlatform;
57 60
 import net.bluemind.mailbox.api.Mailbox.Routing;
61
+import net.bluemind.pool.impl.BmConfIni;
62
+import net.bluemind.server.api.IServer;
58 63
 import net.bluemind.server.api.Server;
59 64
 import net.bluemind.tests.defaultdata.PopulateHelper;
60 65
 import net.bluemind.user.api.IUser;
... ...
@@ -63,12 +68,12 @@ import net.bluemind.user.api.User;
63 68
 public class VEventSanitizerTests {
64 69
 
65 70
 	private BmTestContext test1Context;
71
+	private String domainUid;
66 72
 
67 73
 	@Before
68 74
 	public void beforeBefore() throws Exception {
69 75
 		JdbcTestHelper.getInstance().beforeTest();
70 76
 		JdbcTestHelper.getInstance().getDbSchemaService().initialize();
71
-
72 77
 		final SettableFuture<Void> future = SettableFuture.<Void>create();
73 78
 		Handler<AsyncResult<Void>> done = new Handler<AsyncResult<Void>>() {
74 79
 
... ...
@@ -80,15 +85,21 @@ public class VEventSanitizerTests {
80 85
 		VertxPlatform.spawnVerticles(done);
81 86
 		future.get();
82 87
 
83
-		String domainUid = "bm.lan";
88
+		this.domainUid = "test.lan";
84 89
 
85 90
 		Server esServer = new Server();
86 91
 		esServer.ip = ElasticsearchTestHelper.getInstance().getHost();
87 92
 		esServer.tags = Lists.newArrayList("bm/es");
88 93
 
89
-		PopulateHelper.initGlobalVirt(esServer);
94
+		Server imapServer = new Server();
95
+		imapServer.ip = new BmConfIni().get("imap-role");
96
+		imapServer.tags = Lists.newArrayList("mail/imap");
97
+
98
+		PopulateHelper.initGlobalVirt(esServer, imapServer);
99
+
100
+		PopulateHelper.createTestDomain(domainUid, esServer, imapServer);
90 101
 
91
-		PopulateHelper.createTestDomain(domainUid, esServer);
102
+		this.createCyrusPartition(imapServer, this.domainUid);
92 103
 
93 104
 		BmTestContext systemContext = new BmTestContext(SecurityContext.SYSTEM);
94 105
 		IUser users = systemContext.provider().instance(IUser.class, domainUid);
... ...
@@ -96,13 +107,23 @@ public class VEventSanitizerTests {
96 107
 		users.create("test2", defaultUser("test2"));
97 108
 
98 109
 		test1Context = new BmTestContext(
99
-				new SecurityContext("test1", "test1", Arrays.<String>asList("g1"), Arrays.<String>asList(), "bm.lan"));
110
+				new SecurityContext("test1", "test1", Arrays.<String>asList("g1"), Arrays.<String>asList(), domainUid));
100 111
 
101 112
 		IGroup groups = systemContext.provider().instance(IGroup.class, domainUid);
102
-		groups.create("g1", defaultGroup("g1", PopulateHelper.FAKE_CYRUS_IP));
113
+		groups.create("g1", defaultGroup("g1", imapServer.ip));
103 114
 		groups.add("g1", Arrays.asList(Member.user("test1")));
104 115
 	}
105 116
 
117
+	private void createCyrusPartition(final Server imapServer, final String domainUid) {
118
+		final CyrusService cyrusService = new CyrusService(imapServer.ip);
119
+		cyrusService.createPartition(domainUid);
120
+		cyrusService.refreshPartitions(Arrays.asList(domainUid));
121
+		new CyrusAdmins(
122
+				ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM).instance(IServer.class, "default"),
123
+				imapServer.ip).write();
124
+		cyrusService.reload();
125
+	}
126
+
106 127
 	private Group defaultGroup(String name, String cyrusIp) {
107 128
 		Group g = new Group();
108 129
 		g.dataLocation = cyrusIp;
... ...
@@ -114,7 +135,7 @@ public class VEventSanitizerTests {
114 135
 		User user = new User();
115 136
 		user.login = login;
116 137
 		Email em = new Email();
117
-		em.address = login + "@bm.lan";
138
+		em.address = login + "@" + this.domainUid;
118 139
 		em.isDefault = true;
119 140
 		em.allAliases = false;
120 141
 		user.emails = Arrays.asList(em);
... ...
@@ -129,7 +150,7 @@ public class VEventSanitizerTests {
129 150
 	@Test
130 151
 	public void testSanitizeSimple() throws ServerFault {
131 152
 
132
-		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, "bm.lan");
153
+		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, this.domainUid);
133 154
 
134 155
 		VEvent vevent = new VEvent();
135 156
 
... ...
@@ -149,7 +170,7 @@ public class VEventSanitizerTests {
149 170
 	@Test
150 171
 	public void testOrganizerWithoutEmailCannotCreateMeeting() throws ServerFault {
151 172
 
152
-		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, "bm.lan");
173
+		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, this.domainUid);
153 174
 
154 175
 		VEvent vevent = new VEvent();
155 176
 
... ...
@@ -171,7 +192,7 @@ public class VEventSanitizerTests {
171 192
 	@Test
172 193
 	public void testSanitizeOrganizer() throws ServerFault {
173 194
 
174
-		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, "bm.lan");
195
+		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, this.domainUid);
175 196
 
176 197
 		VEvent vevent = new VEvent();
177 198
 
... ...
@@ -182,13 +203,13 @@ public class VEventSanitizerTests {
182 203
 
183 204
 		vevent.organizer = new Organizer();
184 205
 		vevent.organizer.commonName = "check";
185
-		vevent.organizer.mailto = "test1@bm.lan";
206
+		vevent.organizer.mailto = "test1@" + this.domainUid;
186 207
 		vevent.attendees = Arrays.asList(simpleAttendee());
187 208
 		sanitizer.sanitize(vevent);
188 209
 
189
-		assertEquals("test1@bm.lan", vevent.organizer.mailto);
210
+		assertEquals("test1@" + this.domainUid, vevent.organizer.mailto);
190 211
 		assertEquals("test1 test1", vevent.organizer.commonName);
191
-		assertEquals("bm://bm.lan/users/test1", vevent.organizer.dir);
212
+		assertEquals("bm://" + this.domainUid + "/users/test1", vevent.organizer.dir);
192 213
 
193 214
 		vevent = new VEvent();
194 215
 
... ...
@@ -196,32 +217,32 @@ public class VEventSanitizerTests {
196 217
 		vevent.summary = "event " + System.currentTimeMillis();
197 218
 		vevent.organizer = new Organizer();
198 219
 		vevent.organizer.commonName = "check";
199
-		vevent.organizer.dir = "bm://bm.lan/users/test1";
220
+		vevent.organizer.dir = "bm://" + this.domainUid + "/users/test1";
200 221
 		vevent.attendees = Arrays.asList(simpleAttendee());
201 222
 		sanitizer.sanitize(vevent);
202 223
 
203 224
 		assertEquals("test1 test1", vevent.organizer.commonName);
204
-		assertEquals("test1@bm.lan", vevent.organizer.mailto);
225
+		assertEquals("test1@" + this.domainUid, vevent.organizer.mailto);
205 226
 		assertEquals(1, vevent.attendees.size());
206 227
 
207 228
 		// organizer not in system
208 229
 		vevent.organizer = new Organizer();
209 230
 		vevent.organizer.commonName = "check";
210
-		vevent.organizer.mailto = "fake@bm.lan";
231
+		vevent.organizer.mailto = "fake@" + this.domainUid;
211 232
 		sanitizer.sanitize(vevent);
212 233
 
213
-		assertEquals("fake@bm.lan", vevent.organizer.mailto);
234
+		assertEquals("fake@" + this.domainUid, vevent.organizer.mailto);
214 235
 		assertEquals("check", vevent.organizer.commonName);
215 236
 		assertNull(vevent.organizer.dir);
216 237
 
217 238
 		// organizer not in system
218 239
 		vevent.organizer = new Organizer();
219 240
 		vevent.organizer.commonName = "check";
220
-		vevent.organizer.mailto = "fake@bm.lan";
221
-		vevent.organizer.dir = "bm://bm.lan/users/fake";
241
+		vevent.organizer.mailto = "fake@" + this.domainUid;
242
+		vevent.organizer.dir = "bm://" + this.domainUid + "/users/fake";
222 243
 		sanitizer.sanitize(vevent);
223 244
 
224
-		assertEquals("fake@bm.lan", vevent.organizer.mailto);
245
+		assertEquals("fake@" + this.domainUid, vevent.organizer.mailto);
225 246
 		assertEquals("check", vevent.organizer.commonName);
226 247
 		assertNull(vevent.organizer.dir);
227 248
 
... ...
@@ -235,7 +256,7 @@ public class VEventSanitizerTests {
235 256
 
236 257
 		vevent.organizer = new Organizer();
237 258
 		vevent.organizer.commonName = "check";
238
-		vevent.organizer.mailto = "test1@bm.lan";
259
+		vevent.organizer.mailto = "test1@" + this.domainUid;
239 260
 		sanitizer.sanitize(vevent);
240 261
 		assertNull(vevent.organizer);
241 262
 	}
... ...
@@ -243,7 +264,7 @@ public class VEventSanitizerTests {
243 264
 	@Test
244 265
 	public void testSanitizeOrganizerInvalidMailto() throws ServerFault {
245 266
 
246
-		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, "bm.lan");
267
+		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, this.domainUid);
247 268
 
248 269
 		VEvent vevent = new VEvent();
249 270
 
... ...
@@ -264,7 +285,7 @@ public class VEventSanitizerTests {
264 285
 	private Attendee simpleAttendee() {
265 286
 		Attendee attendee = new VEvent.Attendee();
266 287
 		attendee.commonName = "check";
267
-		attendee.mailto = "test2@bm.lan";
288
+		attendee.mailto = "test2@" + this.domainUid;
268 289
 		attendee.partStatus = ParticipationStatus.NeedsAction;
269 290
 		return attendee;
270 291
 	}
... ...
@@ -272,7 +293,7 @@ public class VEventSanitizerTests {
272 293
 	@Test
273 294
 	public void testSanitizeAttendee() throws ServerFault {
274 295
 
275
-		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, "bm.lan");
296
+		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, this.domainUid);
276 297
 
277 298
 		VEvent vevent = new VEvent();
278 299
 
... ...
@@ -283,15 +304,15 @@ public class VEventSanitizerTests {
283 304
 
284 305
 		Attendee attendee = new VEvent.Attendee();
285 306
 		attendee.commonName = "check";
286
-		attendee.mailto = "test1@bm.lan";
307
+		attendee.mailto = "test1@" + this.domainUid;
287 308
 		vevent.attendees = Arrays.asList(attendee);
288 309
 		vevent.organizer = new Organizer("chef@bad-company.com");
289 310
 		sanitizer.sanitize(vevent);
290 311
 
291 312
 		assertEquals(1, vevent.attendees.size());
292
-		assertEquals("test1@bm.lan", vevent.attendees.get(0).mailto);
313
+		assertEquals("test1@" + this.domainUid, vevent.attendees.get(0).mailto);
293 314
 		assertEquals("test1 test1", vevent.attendees.get(0).commonName);
294
-		assertEquals("bm://bm.lan/users/test1", vevent.attendees.get(0).dir);
315
+		assertEquals("bm://" + this.domainUid + "/users/test1", vevent.attendees.get(0).dir);
295 316
 
296 317
 		vevent = new VEvent();
297 318
 
... ...
@@ -300,15 +321,15 @@ public class VEventSanitizerTests {
300 321
 		attendee = new VEvent.Attendee();
301 322
 		attendee.commonName = "check";
302 323
 		attendee.mailto = "fake@gmail.com";
303
-		attendee.dir = "bm://bm.lan/users/test1";
324
+		attendee.dir = "bm://" + this.domainUid + "/users/test1";
304 325
 		vevent.attendees = Arrays.asList(attendee);
305 326
 		vevent.organizer = new Organizer("chef@bad-company.com");
306 327
 		sanitizer.sanitize(vevent);
307 328
 
308 329
 		// BM-9907 returns user default email
309
-		assertEquals("test1@bm.lan", vevent.attendees.get(0).mailto);
330
+		assertEquals("test1@" + this.domainUid, vevent.attendees.get(0).mailto);
310 331
 		assertEquals("test1 test1", vevent.attendees.get(0).commonName);
311
-		assertEquals("bm://bm.lan/users/test1", vevent.attendees.get(0).dir);
332
+		assertEquals("bm://" + this.domainUid + "/users/test1", vevent.attendees.get(0).dir);
312 333
 
313 334
 		// attendee not in system
314 335
 		vevent = new VEvent();
... ...
@@ -317,14 +338,14 @@ public class VEventSanitizerTests {
317 338
 		vevent.summary = "event " + System.currentTimeMillis();
318 339
 		attendee = new VEvent.Attendee();
319 340
 		attendee.commonName = "check";
320
-		attendee.mailto = "fake@bm.lan";
341
+		attendee.mailto = "fake@" + this.domainUid;
321 342
 		attendee.dir = "fake://test";
322 343
 		vevent.attendees = Arrays.asList(attendee);
323 344
 		vevent.organizer = new Organizer("chef@bad-company.com");
324 345
 
325 346
 		sanitizer.sanitize(vevent);
326 347
 		// not modified
327
-		assertEquals("fake@bm.lan", vevent.attendees.get(0).mailto);
348
+		assertEquals("fake@" + this.domainUid, vevent.attendees.get(0).mailto);
328 349
 		assertEquals("check", vevent.attendees.get(0).commonName);
329 350
 		assertNull(vevent.attendees.get(0).dir);
330 351
 
... ...
@@ -335,13 +356,13 @@ public class VEventSanitizerTests {
335 356
 		vevent.summary = "event " + System.currentTimeMillis();
336 357
 		attendee = new VEvent.Attendee();
337 358
 		attendee.commonName = "check";
338
-		attendee.mailto = "fake@bm.lan";
339
-		attendee.dir = "bm://bm.lan/users/fake";
359
+		attendee.mailto = "fake@" + this.domainUid;
360
+		attendee.dir = "bm://" + this.domainUid + "/users/fake";
340 361
 		vevent.attendees = Arrays.asList(attendee);
341 362
 		vevent.organizer = new Organizer("chef@bad-company.com");
342 363
 		sanitizer.sanitize(vevent);
343 364
 
344
-		assertEquals("fake@bm.lan", vevent.attendees.get(0).mailto);
365
+		assertEquals("fake@" + this.domainUid, vevent.attendees.get(0).mailto);
345 366
 		assertEquals("check", vevent.attendees.get(0).commonName);
346 367
 		assertNull(vevent.attendees.get(0).dir);
347 368
 
... ...
@@ -362,7 +383,7 @@ public class VEventSanitizerTests {
362 383
 		vevent.attendees = Arrays.asList(attendee);
363 384
 		vevent.organizer = new Organizer("chef@bad-company.com");
364 385
 
365
-		new VEventSanitizer(test1Context, "bm.lan").sanitize(vevent);
386
+		new VEventSanitizer(test1Context, this.domainUid).sanitize(vevent);
366 387
 		assertEquals("fake_/email.com", attendee.commonName);
367 388
 		assertNull(attendee.mailto);
368 389
 	}
... ...
@@ -370,7 +391,7 @@ public class VEventSanitizerTests {
370 391
 	@Test
371 392
 	public void testSanitizeExDate() throws ServerFault {
372 393
 
373
-		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, "bm.lan");
394
+		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, this.domainUid);
374 395
 
375 396
 		VEvent vevent = new VEvent();
376 397
 
... ...
@@ -387,16 +408,16 @@ public class VEventSanitizerTests {
387 408
 
388 409
 	@Test
389 410
 	public void testSanitizeOrganizerIsTheOnlyAttendee() {
390
-		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, "bm.lan");
411
+		VEventSanitizer sanitizer = new VEventSanitizer(test1Context, this.domainUid);
391 412
 
392 413
 		VEvent vevent = new VEvent();
393 414
 		vevent.dtstart = BmDateTimeWrapper.create(new DateTime(2015, 05, 01, 0, 0, 0), Precision.Date);
394 415
 		vevent.summary = "event " + System.currentTimeMillis();
395 416
 		Attendee attendee = new VEvent.Attendee();
396 417
 		attendee.commonName = "test1";
397
-		attendee.mailto = "test1@bm.lan";
418
+		attendee.mailto = "test1@" + this.domainUid;
398 419
 		vevent.attendees = Arrays.asList(attendee);
399
-		vevent.organizer = new Organizer("test1@bm.lan");
420
+		vevent.organizer = new Organizer("test1@" + this.domainUid);
400 421
 
401 422
 		VEventSeries series = VEventSeries.create(vevent);
402 423
 
... ...
@@ -44,7 +44,8 @@ Require-Bundle: net.bluemind.calendar.api;bundle-version="1.0.0",
44 44
  net.bluemind.calendar.auditlog;bundle-version="3.1.0",
45 45
  net.bluemind.core.auditlog,
46 46
  net.bluemind.core.caches.registry,
47
- net.bluemind.user.persistance
47
+ net.bluemind.user.persistance,
48
+ net.bluemind.resource.api 
48