Skip to content

Commit 0e46501

Browse files
committed
fix tests
1 parent 939e488 commit 0e46501

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

engine/storage/image/src/test/java/org/apache/cloudstack/storage/image/TemplateServiceImplTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,55 +127,48 @@ public void setUp() {
127127
Mockito.doReturn(templateInfoMock).when(templateDataFactoryMock).getTemplate(2L, sourceStoreMock);
128128
Mockito.doReturn(3L).when(dataStoreMock).getId();
129129
Mockito.doReturn(zoneScopeMock).when(dataStoreMock).getScope();
130-
Mockito.when(imageStoreDao.findById(3L)).thenReturn(imageStoreMock);
131130
}
132131

133132
@Test
134133
public void shouldDownloadTemplateToStoreTestSkipsTemplateDirectedToAnotherStorage() {
135134
DataStore destinedStore = Mockito.mock(DataStore.class);
136-
Mockito.when(imageStoreMock.isReadonly()).thenReturn(false);
137135
Mockito.doReturn(dataStoreMock.getId() + 1L).when(destinedStore).getId();
138136
Mockito.when(templateManagerMock.verifyHeuristicRulesForZone(tmpltMock, zoneScopeMock.getScopeId())).thenReturn(destinedStore);
139137
Assert.assertFalse(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
140138
}
141139

142140
@Test
143141
public void shouldDownloadTemplateToStoreTestDownloadsPublicTemplate() {
144-
Mockito.when(imageStoreMock.isReadonly()).thenReturn(false);
145142
Mockito.when(tmpltMock.isPublicTemplate()).thenReturn(true);
146143
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
147144
}
148145

149146
@Test
150147
public void shouldDownloadTemplateToStoreTestDownloadsFeaturedTemplate() {
151-
Mockito.when(imageStoreMock.isReadonly()).thenReturn(false);
152148
Mockito.when(tmpltMock.isFeatured()).thenReturn(true);
153149
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
154150
}
155151

156152
@Test
157153
public void shouldDownloadTemplateToStoreTestDownloadsSystemTemplate() {
158-
Mockito.when(imageStoreMock.isReadonly()).thenReturn(false);
159154
Mockito.when(tmpltMock.getTemplateType()).thenReturn(Storage.TemplateType.SYSTEM);
160155
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
161156
}
162157

163158
@Test
164159
public void shouldDownloadTemplateToStoreTestDownloadsPrivateNoRefTemplate() {
165-
Mockito.when(imageStoreMock.isReadonly()).thenReturn(false);
166160
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
167161
}
168162

169163
@Test
170164
public void shouldDownloadTemplateToStoreTestSkipsPrivateExistingTemplate() {
171-
Mockito.when(imageStoreMock.isReadonly()).thenReturn(false);
172165
Mockito.when(templateDataStoreDao.findByTemplateZone(tmpltMock.getId(), zoneScopeMock.getScopeId(), DataStoreRole.Image)).thenReturn(Mockito.mock(TemplateDataStoreVO.class));
173166
Assert.assertFalse(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
174167
}
175168

176169
@Test
177170
public void shouldDownloadTemplateToStoreTestSkipsWhenStorageIsReadOnly() {
178-
Mockito.when(imageStoreMock.isReadonly()).thenReturn(true);
171+
Mockito.when(dataStoreManagerMock.isRemovedOrReadonly(Mockito.any())).thenReturn(true);
179172
Assert.assertFalse(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
180173

181174
}

0 commit comments

Comments
 (0)