use of org.xwiki.extension.CoreExtension in project xwiki-platform by xwiki.
the class DistributionPingDataProvider method provideData.
@Override
public Map<String, Object> provideData() {
Map<String, Object> jsonMap = new HashMap<>();
String instanceId = this.instanceIdManagerProvider.get().getInstanceId().toString();
jsonMap.put(PROPERTY_INSTANCE_ID, instanceId);
CoreExtension distributionExtension = this.coreExtensionRepository.getEnvironmentExtension();
if (distributionExtension != null) {
String distributionId = distributionExtension.getId().getId();
if (distributionId != null) {
jsonMap.put(PROPERTY_DISTRIBUTION_ID, distributionId);
}
Version distributionVersion = distributionExtension.getId().getVersion();
if (distributionVersion != null) {
jsonMap.put(PROPERTY_DISTRIBUTION_VERSION, distributionVersion.toString());
}
Collection<String> features = distributionExtension.getFeatures();
if (!features.isEmpty()) {
jsonMap.put(PROPERTY_DISTRIBUTION_FEATURES, distributionExtension.getFeatures().toArray());
}
}
return jsonMap;
}
use of org.xwiki.extension.CoreExtension in project xwiki-platform by xwiki.
the class DistributionPingDataProviderTest method provideData.
@Test
public void provideData() throws Exception {
InstanceId id = new InstanceId(UUID.randomUUID().toString());
InstanceIdManager idManager = this.mocker.getInstance(InstanceIdManager.class);
when(idManager.getInstanceId()).thenReturn(id);
ExtensionId environmentExtensionId = new ExtensionId("environmentextensionid", "2.0");
CoreExtension environmentExtension = mock(CoreExtension.class);
when(environmentExtension.getId()).thenReturn(environmentExtensionId);
CoreExtensionRepository CoreExtensionRepository = this.mocker.getInstance(CoreExtensionRepository.class);
when(CoreExtensionRepository.getEnvironmentExtension()).thenReturn(environmentExtension);
Map<String, Object> data = this.mocker.getComponentUnderTest().provideData();
assertEquals(3, data.size());
assertEquals("environmentextensionid", data.get("distributionId"));
assertEquals("2.0", data.get("distributionVersion"));
assertEquals(id.getInstanceId(), data.get("instanceId"));
}
Aggregations