Search in sources :

Example 1 with CoreExtension

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;
}
Also used : CoreExtension(org.xwiki.extension.CoreExtension) HashMap(java.util.HashMap) Version(org.xwiki.extension.version.Version)

Example 2 with CoreExtension

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"));
}
Also used : InstanceIdManager(org.xwiki.instance.InstanceIdManager) CoreExtension(org.xwiki.extension.CoreExtension) InstanceId(org.xwiki.instance.InstanceId) CoreExtensionRepository(org.xwiki.extension.repository.CoreExtensionRepository) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Aggregations

CoreExtension (org.xwiki.extension.CoreExtension)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ExtensionId (org.xwiki.extension.ExtensionId)1 CoreExtensionRepository (org.xwiki.extension.repository.CoreExtensionRepository)1 Version (org.xwiki.extension.version.Version)1 InstanceId (org.xwiki.instance.InstanceId)1 InstanceIdManager (org.xwiki.instance.InstanceIdManager)1