use of org.codice.ddf.admin.application.rest.model.FeatureDetails in project ddf by codice.
the class ApplicationServiceImplTest method testGetAllFeaturesFTRException.
/**
* Tests the {@link ApplicationServiceImpl#getAllFeatures()} method for the case where an
* exception is thrown in getFeatureToRepository(..)
*/
@Test
public void testGetAllFeaturesFTRException() throws Exception {
Set<Repository> activeRepos = new HashSet<>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl(featuresService);
doThrow(new NullPointerException()).when(featuresService).listRepositories();
List<FeatureDetails> details = appService.getAllFeatures();
assertThat("List of feature details should have 7 entries", details, hasSize(4));
details.forEach(d -> assertThat(d.getName() + " should not have a mapped repository", d.getRepository(), is(nullValue())));
}
use of org.codice.ddf.admin.application.rest.model.FeatureDetails in project ddf by codice.
the class ApplicationServiceBean method getFeatureMap.
private List<Map<String, Object>> getFeatureMap(List<FeatureDetails> featureViews) {
List<Map<String, Object>> features = new ArrayList<>();
for (FeatureDetails feature : featureViews) {
Map<String, Object> featureMap = new HashMap<>();
featureMap.put(MAP_NAME, feature.getName());
featureMap.put(MAP_VERSION, feature.getVersion());
featureMap.put(MAP_STATUS, feature.getStatus());
featureMap.put(MAP_REPOSITORY, feature.getRepository());
features.add(featureMap);
}
return features;
}
use of org.codice.ddf.admin.application.rest.model.FeatureDetails in project ddf by codice.
the class ApplicationServiceBeanTest method testFindApplicationFeatures.
/**
* Tests the {@link ApplicationServiceBean#findApplicationFeatures(String)} method
*
* @throws Exception
*/
@Test
public void testFindApplicationFeatures() throws Exception {
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
List<FeatureDetails> testFeatureDetailsList = new ArrayList<>();
FeatureDetails testFeatureDetails1 = mock(FeatureDetails.class);
testFeatureDetailsList.add(testFeatureDetails1);
when(testFeatureDetails1.getName()).thenReturn(TEST_FEATURE_DETAILS);
when(testFeatureDetails1.getVersion()).thenReturn(TEST_VERSION);
when(testFeatureDetails1.getStatus()).thenReturn(TEST_FEATURE_STATUS);
when(testFeatureDetails1.getRepository()).thenReturn(TEST_REPO_NAME);
when(testAppService.findApplicationFeatures(TEST_APP_NAME)).thenReturn(testFeatureDetailsList);
assertThat("Features returned should match testFeatureDetailsList features", (String) serviceBean.findApplicationFeatures(TEST_APP_NAME).get(0).get("name"), is(testFeatureDetailsList.get(0).getName()));
verify(testAppService).findApplicationFeatures(TEST_APP_NAME);
}
use of org.codice.ddf.admin.application.rest.model.FeatureDetails in project ddf by codice.
the class ApplicationServiceImplTest method testFindApplicationFeatures.
/**
* Tests the {@link ApplicationServiceImpl#findApplicationFeatures(String)} method
*
* @throws Exception
*/
@Test
public void testFindApplicationFeatures() throws Exception {
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1, noMainFeatureRepo2));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = createPermittedApplicationServiceImpl();
Feature testFeature1 = mock(Feature.class);
Feature[] featureList = { testFeature1 };
Repository testRepo = mock(Repository.class);
when(testFeature1.getRepositoryUrl()).thenReturn(TEST_REPO_URI);
when(testRepo.getURI()).thenReturn(new URI(TEST_REPO_URI));
when(testRepo.getFeatures()).thenReturn(featureList);
Repository[] repositoryList = { testRepo };
when(featuresService.getFeature(TEST_APP_NAME)).thenReturn(testFeature1);
when(featuresService.listRepositories()).thenReturn(repositoryList);
when(featuresService.isInstalled(testFeature1)).thenReturn(true);
List<FeatureDetails> result = appService.findApplicationFeatures(TEST_APP_NAME);
assertThat("Should return one feature.", result.size(), is(1));
}
use of org.codice.ddf.admin.application.rest.model.FeatureDetails in project ddf by codice.
the class ApplicationServiceBeanTest method testGetAllFeatures.
/**
* Tests the {@link ApplicationServiceBean#getAllFeatures()} method
*
* @throws Exception
*/
@Test
public void testGetAllFeatures() throws Exception {
ApplicationServiceBean serviceBean = newApplicationServiceBean();
List<FeatureDetails> testFeatureDetailsList = new ArrayList<>();
FeatureDetails testFeatureDetails1 = mock(FeatureDetails.class);
testFeatureDetailsList.add(testFeatureDetails1);
when(testFeatureDetails1.getName()).thenReturn(TEST_FEATURE_DETAILS);
when(testFeatureDetails1.getVersion()).thenReturn(TEST_VERSION);
when(testFeatureDetails1.getStatus()).thenReturn(TEST_FEATURE_STATUS);
when(testFeatureDetails1.getRepository()).thenReturn(TEST_REPO_NAME);
when(testAppService.getAllFeatures()).thenReturn(testFeatureDetailsList);
assertThat("Features returned should match testFeatureDetailsList features", (String) serviceBean.getAllFeatures().get(0).get("name"), is(testFeatureDetailsList.get(0).getName()));
verify(testAppService).getAllFeatures();
}
Aggregations