diff options
author | 2019-08-07 16:43:54 +0200 | |
---|---|---|
committer | 2019-08-08 06:29:36 +0000 | |
commit | b86fbc87516250b0267cf35479cd8deb7ef42326 (patch) | |
tree | 61c849fc11beb79c349524edd45470f6e7e31d34 /openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org | |
parent | 430315ac3ff6d557a128b8611a2e7a30ca757a86 (diff) |
Additional unit tests
Tests for ConflictsDaoImpl
Change-Id: I7fd472b55a96a314992be0e49725d8844167ff4d
Issue-ID: SDC-2326
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org')
2 files changed, 10 insertions, 7 deletions
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java index 23c90a9044..1ae13b8c48 100644 --- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java +++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java @@ -24,11 +24,12 @@ package org.openecomp.conflicts.dao.impl.zusammen; import org.openecomp.conflicts.dao.ConflictsDao; import org.openecomp.conflicts.dao.ConflictsDaoFactory; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; +import org.openecomp.core.zusammen.api.ZusammenUtil; public class ConflictsDaoFactoryImpl extends ConflictsDaoFactory { private static final ConflictsDao INSTANCE = new - ConflictsDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface()); + ConflictsDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface(), ZusammenUtil::createSessionContext); @Override public ConflictsDao createInterface() { diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java index 713f193ddf..ecc0a3c7ab 100644 --- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java +++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java @@ -29,6 +29,7 @@ import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Item; import com.amdocs.zusammen.datatypes.item.ItemVersion; import com.amdocs.zusammen.datatypes.item.Resolution; +import java.util.function.Supplier; import org.openecomp.conflicts.dao.ConflictsDao; import org.openecomp.conflicts.types.Conflict; import org.openecomp.conflicts.types.ConflictResolution; @@ -41,20 +42,21 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.*; import org.openecomp.sdc.versioning.dao.types.Version; import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement; -import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext; public class ConflictsDaoImpl implements ConflictsDao { private final ZusammenAdaptor zusammenAdaptor; + private final Supplier<SessionContext> sessionContextProvider; - public ConflictsDaoImpl(ZusammenAdaptor zusammenAdaptor) { + public ConflictsDaoImpl(ZusammenAdaptor zusammenAdaptor, Supplier<SessionContext> sessionContextProvider) { this.zusammenAdaptor = zusammenAdaptor; + this.sessionContextProvider = sessionContextProvider; } @Override public boolean isConflicted(String itemId, Version version) { com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict itemVersionConflict = zusammenAdaptor - .getVersionConflict(createSessionContext(), new Id(itemId), new Id(version.getId())); + .getVersionConflict(sessionContextProvider.get(), new Id(itemId), new Id(version.getId())); return !(itemVersionConflict == null || (itemVersionConflict.getVersionDataConflict() == null && itemVersionConflict.getElementConflictInfos().isEmpty())); @@ -64,12 +66,12 @@ public class ConflictsDaoImpl implements ConflictsDao { public ItemVersionConflict getConflict(String itemId, Version version) { return new ItemVersionConflictConvertorFromZusammen().convert(itemId, version, zusammenAdaptor - .getVersionConflict(createSessionContext(), new Id(itemId), new Id(version.getId()))); + .getVersionConflict(sessionContextProvider.get(), new Id(itemId), new Id(version.getId()))); } @Override public Conflict getConflict(String itemId, Version version, String conflictId) { - return zusammenAdaptor.getElementConflict(createSessionContext(), + return zusammenAdaptor.getElementConflict(sessionContextProvider.get(), new ElementContext(new Id(itemId), new Id(version.getId())), new Id(conflictId)) .map(elementConflict -> convertElementConflict(conflictId, elementConflict)) .orElse(null); @@ -78,7 +80,7 @@ public class ConflictsDaoImpl implements ConflictsDao { @Override public void resolveConflict(String itemId, Version version, String conflictId, ConflictResolution conflictResolution) { - SessionContext context = createSessionContext(); + SessionContext context = sessionContextProvider.get(); ElementContext elementContext = new ElementContext(new Id(itemId), new Id(version.getId())); // TODO: 7/31/2017 when 'OTHER' resolution will be supported - populate zusammen element with it |