@Test public void testUpdateSameQuotaWithoutChangingName() throws Exception { List<String> messages = new ArrayList<String>(); Quota mockQuota = mockGeneralStorageQuota(); when(quotaDAO.getQuotaByQuotaName(quotaName)).thenReturn(mockQuota); boolean isQuotaValid = quotaHelper.checkQuotaNameExisting(mockQuota, messages); assertTrue(isQuotaValid); }
@Test public void testQuotaWithSameNameExists() throws Exception { List<String> messages = new ArrayList<String>(); Quota mockQuota = mockGeneralStorageQuota(); when(quotaDAO.getQuotaByQuotaName(quotaName)).thenReturn(mockQuota); Quota sameMockedQuotaWithDifferentId = mockGeneralStorageQuota(); boolean isQuotaValid = quotaHelper.checkQuotaNameExisting(sameMockedQuotaWithDifferentId, messages); assertTrue( messages.contains(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_NAME_ALREADY_EXISTS.toString())); assertFalse(isQuotaValid); }