Browse code

BM-12638 Fix: user tag restore

David Phan authored on 08/02/2018 14:40:19
Showing 2 changed files
... ...
@@ -226,12 +226,16 @@ public class RestoreUserTests {
226 226
 
227 227
 		doBackup();
228 228
 		testContext.provider().instance(IUser.class, domain).delete(changUid);
229
+		assertEquals(0, tagsService.all().size()); // ensure tag is deleted
230
+
229 231
 		RestoreUserTask ru = new RestoreUserTask(latestGen, restorable);
230 232
 		TestMonitor monitor = new TestMonitor();
231 233
 		ru.run(monitor);
232 234
 
233 235
 		ItemValue<User> restoredUser = testContext.provider().instance(IUser.class, domain).getComplete(changUid);
234 236
 		assertNotNull(restoredUser);
237
+
238
+		tagsService = testContext.provider().instance(ITags.class, "tags_" + changUid);
235 239
 		assertEquals(1, tagsService.all().size());
236 240
 		ItemValue<Tag> tag = tagsService.getComplete("testRestoreUserTags");
237 241
 		assertEquals("string", tag.value.label);
... ...
@@ -144,8 +144,8 @@ public class RestoreUserTask implements IServerTask {
144 144
 	}
145 145
 
146 146
 	private void restoreUserTags(Restorable item, IServiceProvider live, IServiceProvider back) {
147
-		ITags tagsBackup = back.instance(ITags.class, TagsContainerType.TYPE + "_" + item.domainUid);
148
-		ITags tagsLive = live.instance(ITags.class, TagsContainerType.TYPE + "_" + item.domainUid);
147
+		ITags tagsBackup = back.instance(ITags.class, TagsContainerType.TYPE + "_" + item.entryUid);
148
+		ITags tagsLive = live.instance(ITags.class, TagsContainerType.TYPE + "_" + item.entryUid);
149 149
 		List<TagChanges.ItemAdd> userTags = new ArrayList<>();
150 150
 		for (ItemValue<Tag> t : tagsBackup.all()) {
151 151
 			userTags.add(ItemAdd.create(t.uid, t.value));