Example usage for com.liferay.portal.kernel.util LongWrapper getValue

List of usage examples for com.liferay.portal.kernel.util LongWrapper getValue

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util LongWrapper getValue.

Prototype

public long getValue() 

Source Link

Usage

From source file:com.liferay.content.targeting.service.test.lar.BasePortletDataHandlerTestCase.java

License:Open Source License

protected void checkManifestSummary(Map<String, LongWrapper> expectedModelAdditionCounters) {

    ManifestSummary manifestSummary = portletDataContext.getManifestSummary();

    Map<String, LongWrapper> modelAdditionCounters = manifestSummary.getModelAdditionCounters();

    int expectedModelAdditionCountersSize = expectedModelAdditionCounters.size();

    for (String manifestSummaryKey : expectedModelAdditionCounters.keySet()) {

        LongWrapper expectedModelAdditionCounter = expectedModelAdditionCounters.get(manifestSummaryKey);
        LongWrapper modelAdditionCounter = modelAdditionCounters.get(manifestSummaryKey);

        if ((expectedModelAdditionCounter.getValue() == 0) && (modelAdditionCounter == null)) {

            expectedModelAdditionCountersSize--;
        } else {/*from w ww. j  a va2 s. com*/
            Assert.assertEquals(expectedModelAdditionCounter.getValue(), modelAdditionCounter.getValue());
        }
    }

    Assert.assertEquals(modelAdditionCounters.size(), expectedModelAdditionCountersSize);
}

From source file:com.liferay.document.library.web.exportimport.data.handler.test.DLPortletDataHandlerTest.java

License:Open Source License

@Test
public void testCustomRepositoryEntriesExport() throws Exception {
    initExport();/*from  w  ww.j av  a 2  s  . co  m*/

    addRepositoryEntries();

    portletDataContext.setEndDate(getEndDate());

    portletDataHandler.prepareManifestSummary(portletDataContext);

    ManifestSummary manifestSummary = portletDataContext.getManifestSummary();

    Map<String, LongWrapper> modelAdditionCounters = manifestSummary.getModelAdditionCounters();

    LongWrapper fileEntryModelAdditionCounter = modelAdditionCounters.get(DLFileEntry.class.getName());

    Assert.assertEquals(0, fileEntryModelAdditionCounter.getValue());

    LongWrapper folderModelAdditionCounter = modelAdditionCounters.get(DLFolder.class.getName());

    Assert.assertEquals(0, folderModelAdditionCounter.getValue());

    modelAdditionCounters.clear();

    portletDataHandler.exportData(portletDataContext, portletId, new PortletPreferencesImpl());

    manifestSummary = portletDataContext.getManifestSummary();

    modelAdditionCounters = manifestSummary.getModelAdditionCounters();

    fileEntryModelAdditionCounter = modelAdditionCounters.get(DLFileEntry.class.getName());

    Assert.assertEquals(0, fileEntryModelAdditionCounter.getValue());

    folderModelAdditionCounter = modelAdditionCounters.get(DLFolder.class.getName());

    Assert.assertEquals(0, folderModelAdditionCounter.getValue());
}

From source file:com.liferay.exportimport.internal.background.task.DefaultExportImportBackgroundTaskStatusMessageTranslator.java

License:Open Source License

protected long getTotal(Map<String, LongWrapper> modelCounters) {
    if (modelCounters == null) {
        return 0;
    }/*from   www. j av a 2s . c o  m*/

    long total = 0;

    for (Map.Entry<String, LongWrapper> entry : modelCounters.entrySet()) {
        LongWrapper longWrapper = entry.getValue();

        total += longWrapper.getValue();
    }

    return total;
}