@Test public void test_should_delete_messages() { final MessageIdentity messageIdentity1 = MessageIdentity.builder() .code("code1") .locale(MR_IN) .module("module1") .tenant(new Tenant("tenant1")) .build(); final MessageIdentity messageIdentity2 = MessageIdentity.builder() .code("code2") .locale(ENGLISH_INDIA) .module("module2") .tenant(new Tenant("tenant1")) .build(); final MessageIdentity messageIdentity3 = MessageIdentity.builder() .code("code3") .locale(ENGLISH_INDIA) .module("module3") .tenant(new Tenant("tenant2")) .build(); List<MessageIdentity> messageIdentities = Arrays.asList(messageIdentity1, messageIdentity2, messageIdentity3); messageService.delete(messageIdentities); verify(messageRepository, times(1)) .delete("tenant1", MR_IN, "module1", Collections.singletonList("code1")); verify(messageRepository, times(1)) .delete("tenant1", ENGLISH_INDIA, "module2", Collections.singletonList("code2")); verify(messageRepository, times(1)) .delete("tenant2", ENGLISH_INDIA, "module3", Collections.singletonList("code3")); }
public void delete(List<MessageIdentity> messageIdentities) { final Map<Tenant, List<MessageIdentity>> tenantToMessageIdentitiesMap = messageIdentities.stream() .collect(Collectors.groupingBy(MessageIdentity::getTenant)); tenantToMessageIdentitiesMap.keySet() .forEach(tenant -> deleteMessagesForGivenTenant(tenantToMessageIdentitiesMap, tenant)); }
MessageService { public void delete(List<MessageIdentity> messageIdentities) { final Map<Tenant, List<MessageIdentity>> tenantToMessageIdentitiesMap = messageIdentities.stream() .collect(Collectors.groupingBy(MessageIdentity::getTenant)); tenantToMessageIdentitiesMap.keySet() .forEach(tenant -> deleteMessagesForGivenTenant(tenantToMessageIdentitiesMap, tenant)); } }
MessageService { public void delete(List<MessageIdentity> messageIdentities) { final Map<Tenant, List<MessageIdentity>> tenantToMessageIdentitiesMap = messageIdentities.stream() .collect(Collectors.groupingBy(MessageIdentity::getTenant)); tenantToMessageIdentitiesMap.keySet() .forEach(tenant -> deleteMessagesForGivenTenant(tenantToMessageIdentitiesMap, tenant)); } MessageService(MessageRepository messageRepository, MessageCacheRepository messageCacheRepository); }
MessageService { public void delete(List<MessageIdentity> messageIdentities) { final Map<Tenant, List<MessageIdentity>> tenantToMessageIdentitiesMap = messageIdentities.stream() .collect(Collectors.groupingBy(MessageIdentity::getTenant)); tenantToMessageIdentitiesMap.keySet() .forEach(tenant -> deleteMessagesForGivenTenant(tenantToMessageIdentitiesMap, tenant)); } MessageService(MessageRepository messageRepository, MessageCacheRepository messageCacheRepository); void upsert(Tenant tenant, List<Message> messages, AuthenticatedUser user); void create(Tenant tenant, List<Message> messages, AuthenticatedUser user); void updateMessagesForModule(Tenant tenant, List<Message> messages, AuthenticatedUser user); void bustCache(); List<Message> getFilteredMessages(MessageSearchCriteria searchCriteria); void delete(List<MessageIdentity> messageIdentities); }
MessageService { public void delete(List<MessageIdentity> messageIdentities) { final Map<Tenant, List<MessageIdentity>> tenantToMessageIdentitiesMap = messageIdentities.stream() .collect(Collectors.groupingBy(MessageIdentity::getTenant)); tenantToMessageIdentitiesMap.keySet() .forEach(tenant -> deleteMessagesForGivenTenant(tenantToMessageIdentitiesMap, tenant)); } MessageService(MessageRepository messageRepository, MessageCacheRepository messageCacheRepository); void upsert(Tenant tenant, List<Message> messages, AuthenticatedUser user); void create(Tenant tenant, List<Message> messages, AuthenticatedUser user); void updateMessagesForModule(Tenant tenant, List<Message> messages, AuthenticatedUser user); void bustCache(); List<Message> getFilteredMessages(MessageSearchCriteria searchCriteria); void delete(List<MessageIdentity> messageIdentities);  }