Search in sources :

Example 1 with ProductInfo

use of com.adobe.granite.license.ProductInfo in project acs-aem-commons by Adobe-Consulting-Services.

the class DuckDuckGoDocsOperationImpl method activate.

@Activate
protected void activate(Map<String, String> config) {
    ProductInfo productInfo = null;
    for (ProductInfo i : productInfoService.getInfos()) {
        String shortName = i.getShortName();
        // currently, this is always 'CQ' but let's futureproof a bit
        if (shortName.equalsIgnoreCase("cq") || shortName.equalsIgnoreCase("aem")) {
            productInfo = i;
            break;
        }
    }
    if (productInfo != null) {
        // there's a bug in 6.1 GA which causes productInfo.getShortVersion() to return 6.0,
        // so let's use this longer form.
        aemVersion = String.format("%s-%s", productInfo.getVersion().getMajor(), productInfo.getVersion().getMinor());
    }
    log.debug("AEM Version: {}", aemVersion);
    log.debug("Product Name: {}", productName);
}
Also used : ProductInfo(com.adobe.granite.license.ProductInfo) Activate(org.apache.felix.scr.annotations.Activate)

Example 2 with ProductInfo

use of com.adobe.granite.license.ProductInfo in project acs-aem-commons by Adobe-Consulting-Services.

the class HealthCheckStatusEmailerTest method setUp.

@Before
public void setUp() throws Exception {
    config = new HashMap<String, Object>();
    config.put(HealthCheckStatusEmailer.PROP_RECIPIENTS_EMAIL_ADDRESSES, "test@example.com");
    // Success
    HealthCheckMetadata successMetadata = mock(HealthCheckMetadata.class);
    Result successResult = mock(Result.class);
    when(successMetadata.getTitle()).thenReturn("hc success");
    when(successResult.isOk()).thenReturn(true);
    when(successResult.getStatus()).thenReturn(Result.Status.OK);
    when(successExecutionResult.getHealthCheckMetadata()).thenReturn(successMetadata);
    when(successExecutionResult.getHealthCheckResult()).thenReturn(successResult);
    // Failure
    HealthCheckMetadata failureMetadata = mock(HealthCheckMetadata.class);
    Result failureResult = mock(Result.class);
    when(failureMetadata.getTitle()).thenReturn("hc failure");
    when(failureResult.isOk()).thenReturn(false);
    when(failureResult.getStatus()).thenReturn(Result.Status.CRITICAL);
    when(failureExecutionResult.getHealthCheckMetadata()).thenReturn(failureMetadata);
    when(failureExecutionResult.getHealthCheckResult()).thenReturn(failureResult);
    results = new ArrayList<>();
    when(healthCheckExecutor.execute(any(HealthCheckExecutionOptions.class), any(String[].class))).thenReturn(results);
    when(productInfoService.getInfos()).thenReturn(new ProductInfo[] { mock(ProductInfo.class) });
    Set<String> runModes = new HashSet<String>();
    runModes.add("author");
    when(slingSettingsService.getRunModes()).thenReturn(runModes);
}
Also used : ProductInfo(com.adobe.granite.license.ProductInfo) HealthCheckMetadata(org.apache.sling.hc.util.HealthCheckMetadata) HealthCheckExecutionOptions(org.apache.sling.hc.api.execution.HealthCheckExecutionOptions) Result(org.apache.sling.hc.api.Result) HealthCheckExecutionResult(org.apache.sling.hc.api.execution.HealthCheckExecutionResult) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

ProductInfo (com.adobe.granite.license.ProductInfo)2 HashSet (java.util.HashSet)1 Activate (org.apache.felix.scr.annotations.Activate)1 Result (org.apache.sling.hc.api.Result)1 HealthCheckExecutionOptions (org.apache.sling.hc.api.execution.HealthCheckExecutionOptions)1 HealthCheckExecutionResult (org.apache.sling.hc.api.execution.HealthCheckExecutionResult)1 HealthCheckMetadata (org.apache.sling.hc.util.HealthCheckMetadata)1 Before (org.junit.Before)1