|
35 | 35 | import static org.mockito.Mockito.doAnswer;
|
36 | 36 | import static org.mockito.Mockito.mock;
|
37 | 37 | import static org.mockito.Mockito.mockStatic;
|
| 38 | +import static org.mockito.Mockito.verify; |
38 | 39 | import static org.mockito.Mockito.when;
|
39 | 40 |
|
40 | 41 | public class KubernetesResourceInfoTest {
|
@@ -297,6 +298,54 @@ public void create_returns_empty_info_for_unsupported_file_type() {
|
297 | 298 | assertThat(resourceInfo.getNamespace()).isNull();
|
298 | 299 | }
|
299 | 300 |
|
| 301 | + @Test |
| 302 | + public void getApiGroup_returns_apiGroup_of_typeInfo() { |
| 303 | + // given |
| 304 | + KubernetesResourceInfo info = new KubernetesResourceInfo("obiwan", "stewjon", typeInfo); |
| 305 | + |
| 306 | + // when |
| 307 | + info.getApiGroup(); |
| 308 | + |
| 309 | + // then |
| 310 | + verify(typeInfo).getApiGroup(); |
| 311 | + } |
| 312 | + |
| 313 | + @Test |
| 314 | + public void getApiGroup_returns_null_given_typeInfo_is_null() { |
| 315 | + // given |
| 316 | + KubernetesResourceInfo info = new KubernetesResourceInfo("obiwan", "tatooine", null); |
| 317 | + |
| 318 | + // when |
| 319 | + String apiGroup = info.getApiGroup(); |
| 320 | + |
| 321 | + // then |
| 322 | + assertThat(apiGroup).isNull(); |
| 323 | + } |
| 324 | + |
| 325 | + @Test |
| 326 | + public void getKind_returns_kind_of_typeInfo() { |
| 327 | + // given |
| 328 | + KubernetesResourceInfo info = new KubernetesResourceInfo("luke", "stewjon", typeInfo); |
| 329 | + |
| 330 | + // when |
| 331 | + info.getKind(); |
| 332 | + |
| 333 | + // then |
| 334 | + verify(typeInfo).getKind(); |
| 335 | + } |
| 336 | + |
| 337 | + @Test |
| 338 | + public void getKind_returns_null_given_typeInfo_is_nul() { |
| 339 | + // given |
| 340 | + KubernetesResourceInfo info = new KubernetesResourceInfo("luke", "stewjon", null); |
| 341 | + |
| 342 | + // when |
| 343 | + String kind = info.getKind(); |
| 344 | + |
| 345 | + // then |
| 346 | + assertThat(kind).isNull(); |
| 347 | + } |
| 348 | + |
300 | 349 | private void mockCreateKubernetesTypeInfo(KubernetesTypeInfo typeInfo, PsiFile file) {
|
301 | 350 | mockStatic.when(() -> KubernetesTypeInfo.create(file))
|
302 | 351 | .thenReturn(typeInfo);
|
|
0 commit comments