Extended tests for tag toggle and fixed a typo on the assigment result

classes.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-03-27 10:39:29 +02:00
parent c9566e61ce
commit 8a26ded4c4
22 changed files with 232 additions and 183 deletions

View File

@@ -8,14 +8,14 @@
*/
package org.eclipse.hawkbit.eventbus.event;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
/**
* A event for assignment target tag.
*/
public class DistributionSetTagAssigmentResultEvent {
private final DistributionSetTagAssigmentResult assigmentResult;
private final DistributionSetTagAssignmentResult assigmentResult;
/**
* Constructor.
@@ -23,11 +23,11 @@ public class DistributionSetTagAssigmentResultEvent {
* @param assigmentResult
* the assignment result-
*/
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssigmentResult assigmentResult) {
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult) {
this.assigmentResult = assigmentResult;
}
public DistributionSetTagAssigmentResult getAssigmentResult() {
public DistributionSetTagAssignmentResult getAssigmentResult() {
return assigmentResult;
}

View File

@@ -8,14 +8,14 @@
*/
package org.eclipse.hawkbit.eventbus.event;
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
/**
* A event for assignment target tag.
*/
public class TargetTagAssigmentResultEvent {
private final TargetTagAssigmentResult assigmentResult;
private final TargetTagAssignmentResult assigmentResult;
/**
* Constructor.
@@ -23,11 +23,11 @@ public class TargetTagAssigmentResultEvent {
* @param assigmentResult
* the assignment result-
*/
public TargetTagAssigmentResultEvent(final TargetTagAssigmentResult assigmentResult) {
public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult) {
this.assigmentResult = assigmentResult;
}
public TargetTagAssigmentResult getAssigmentResult() {
public TargetTagAssignmentResult getAssigmentResult() {
return assigmentResult;
}

View File

@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata_;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.DistributionSetTypeElement;
import org.eclipse.hawkbit.repository.model.DistributionSet_;
@@ -68,9 +68,6 @@ import com.google.common.eventbus.EventBus;
/**
* Business facade for managing the {@link DistributionSet}s.
*
*
*
*
*/
@Transactional(readOnly = true)
@Validated
@@ -140,15 +137,15 @@ public class DistributionSetManagement {
* @param sets
* to toggle for
* @param tag
* to toogle
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
* to toggle
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
* the assignment outcome.
*/
@Modifying
@Transactional
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final List<DistributionSet> sets,
public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final List<DistributionSet> sets,
@NotNull final DistributionSetTag tag) {
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
}
@@ -163,42 +160,42 @@ public class DistributionSetManagement {
* to toggle for
* @param tagName
* to toggle
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
* the assignment outcome.
*/
@Modifying
@Transactional
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection<Long> dsIds,
public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection<Long> dsIds,
@NotNull final String tagName) {
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
DistributionSetTagAssigmentResult result;
final List<DistributionSet> allDSs = new ArrayList<>();
DistributionSetTagAssignmentResult result;
final List<DistributionSet> toBeChangedDSs = new ArrayList<>();
for (final DistributionSet set : sets) {
if (set.getTags().add(myTag)) {
allDSs.add(set);
toBeChangedDSs.add(set);
}
}
// unassigment case
if (allDSs.isEmpty()) {
// un-assignment case
if (toBeChangedDSs.isEmpty()) {
for (final DistributionSet set : sets) {
if (set.getTags().remove(myTag)) {
allDSs.add(set);
toBeChangedDSs.add(set);
}
}
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(),
Collections.emptyList(), distributionSetRepository.save(allDSs), myTag);
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), 0, toBeChangedDSs.size(),
Collections.emptyList(), distributionSetRepository.save(toBeChangedDSs), myTag);
} else {
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0,
distributionSetRepository.save(allDSs), Collections.emptyList(), myTag);
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), toBeChangedDSs.size(), 0,
distributionSetRepository.save(toBeChangedDSs), Collections.emptyList(), myTag);
}
final DistributionSetTagAssigmentResult resultAssignment = result;
final DistributionSetTagAssignmentResult resultAssignment = result;
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
// no reason to persist the tag
@@ -436,7 +433,7 @@ public class DistributionSetManagement {
* @param spec
* of the search
* @param pageable
* parametsr for paging
* parameter for paging
*
* @return the found {@link SoftwareModuleType}s
*/
@@ -1059,7 +1056,7 @@ public class DistributionSetManagement {
afterCommit.afterCommit(() -> {
final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0,
final DistributionSetTagAssignmentResult result = new DistributionSetTagAssignmentResult(0, save.size(), 0,
save, Collections.emptyList(), tag);
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
});

View File

@@ -258,10 +258,6 @@ public class SoftwareManagement {
return artifactManagement.findSoftwareModuleById(id);
}
// TODO: discuss this method, does not seem to make sense to search by name
// and version without type. It also makes no sense to return collection
// here. It should be a single result based on ytpe,name,version (like the
// constraint).
/**
* retrieves {@link SoftwareModule}s by their name AND version.
*
@@ -269,13 +265,15 @@ public class SoftwareManagement {
* of the {@link SoftwareModule}
* @param version
* of the {@link SoftwareModule}
* @return the found {@link SoftwareModule}s
* @param type
* of the {@link SoftwareModule}
* @return the found {@link SoftwareModule} or <code>null</code>
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
public List<SoftwareModule> findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
@NotEmpty final String version) {
public SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
@NotEmpty final String version, @NotNull final SoftwareModuleType type) {
return softwareModuleRepository.findByNameAndVersion(name, version);
return softwareModuleRepository.findOneByNameAndVersionAndType(name, version, type);
}
/**

View File

@@ -43,15 +43,19 @@ public interface SoftwareModuleRepository
Long countByType(SoftwareModuleType type);
/**
* Retrieves {@link SoftwareModule}s by filtering on name AND version.
* Retrieves {@link SoftwareModule} by filtering on name AND version AND
* type (which is unique per tenant.
*
* @param name
* to be filtered on
* @param version
* to be filtered on
* @return the found {@link SoftwareModule}s with the given name AND verion
* @param type
* to be filtered on
* @return the found {@link SoftwareModule} with the given name AND version
* AND type
*/
List<SoftwareModule> findByNameAndVersion(String name, String version);
SoftwareModule findOneByNameAndVersionAndType(String name, String version, SoftwareModuleType type);
/**
* deletes the {@link SoftwareModule}s with the given IDs.

View File

@@ -11,10 +11,10 @@ package org.eclipse.hawkbit.repository.model;
import java.util.List;
/**
* Result object for {@link DistributionSetTag} assigments.
* Result object for {@link DistributionSetTag} assignments.
*
*/
public class DistributionSetTagAssigmentResult extends AssignmentResult {
public class DistributionSetTagAssignmentResult extends AssignmentResult {
private final int unassigned;
private final List<DistributionSet> assignedDs;
@@ -37,7 +37,7 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
* @param distributionSetTag
* the assigned or unassigned tag
*/
public DistributionSetTagAssigmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
public DistributionSetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
final List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
final DistributionSetTag distributionSetTag) {
super(assigned, alreadyAssigned);
@@ -47,30 +47,18 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
this.distributionSetTag = distributionSetTag;
}
/**
* @return the unassigned
*/
public int getUnassigned() {
return unassigned;
}
/**
* @return the distributionSetTag
*/
public DistributionSetTag getDistributionSetTag() {
return distributionSetTag;
}
/**
* @return the assignedDs
*/
public List<DistributionSet> getAssignedDs() {
return assignedDs;
}
/**
* @return the unassignedDs
*/
public List<DistributionSet> getUnassignedDs() {
return unassignedDs;
}

View File

@@ -11,13 +11,10 @@ package org.eclipse.hawkbit.repository.model;
import java.util.List;
/**
* Result object for {@link TargetTag} assigments.
*
*
*
* Result object for {@link TargetTag} assignments.
*
*/
public class TargetTagAssigmentResult extends AssignmentResult {
public class TargetTagAssignmentResult extends AssignmentResult {
private final int unassigned;
private final List<Target> assignedTargets;
@@ -40,7 +37,7 @@ public class TargetTagAssigmentResult extends AssignmentResult {
* @param targetTag
* the assigned or unassigned tag
*/
public TargetTagAssigmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
public TargetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
final List<Target> assignedTargets, final List<Target> unassignedTargets, final TargetTag targetTag) {
super(assigned, alreadyAssigned);
this.unassigned = unassigned;
@@ -49,23 +46,14 @@ public class TargetTagAssigmentResult extends AssignmentResult {
this.targetTag = targetTag;
}
/**
* @return the unassigned
*/
public int getUnassigned() {
return unassigned;
}
/**
* @return the assignedTargets
*/
public List<Target> getAssignedTargets() {
return assignedTargets;
}
/**
* @return the unassignedTargets
*/
public List<Target> getUnassignedTargets() {
return unassignedTargets;
}

View File

@@ -143,7 +143,7 @@ public class TestDataUtil {
}
public static List<DistributionSetTag> generateDistributionSetTags(final int number) {
final List<DistributionSetTag> result = new ArrayList<DistributionSetTag>();
final List<DistributionSetTag> result = new ArrayList<>();
for (int i = 0; i < number; i++) {
result.add(new DistributionSetTag("tag" + i, "tagdesc" + i, "" + i));

View File

@@ -9,7 +9,6 @@
package org.eclipse.hawkbit.repository;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
@@ -43,7 +42,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
distributionSetManagement);
Target savedTarget = targetManagement.createTarget(target);
final List<Target> toAssign = new ArrayList<Target>();
final List<Target> toAssign = new ArrayList<>();
toAssign.add(savedTarget);
assertThat(savedTarget.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
@@ -74,8 +73,8 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
.isEqualTo(3);
}
@Test
@Description("Register a controller which not exist")
@Test(expected = ConstraintViolationException.class)
@Description("Register a controller which does not exist")
public void testfindOrRegisterTargetIfItDoesNotexist() {
final Target target = controllerManagament.findOrRegisterTargetIfItDoesNotexist("AA", null);
assertThat(target).as("target should not be null").isNotNull();
@@ -84,12 +83,8 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
assertThat(target).as("Target should be the equals").isEqualTo(sameTarget);
assertThat(targetRepository.count()).as("Only 1 target should be registred").isEqualTo(1L);
try {
controllerManagament.findOrRegisterTargetIfItDoesNotexist("", null);
fail("target with empty controller id should not be registred");
} catch (final ConstraintViolationException e) {
// ok
}
// throws exception
controllerManagament.findOrRegisterTargetIfItDoesNotexist("", null);
}
@Test
@@ -101,7 +96,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
distributionSetManagement);
Target savedTarget = targetManagement.createTarget(target);
final List<Target> toAssign = new ArrayList<Target>();
final List<Target> toAssign = new ArrayList<>();
toAssign.add(savedTarget);
savedTarget = deploymentManagement.assignDistributionSet(ds, toAssign).getAssignedTargets().iterator().next();
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
@@ -124,7 +119,7 @@ public class ControllerManagementTest extends AbstractIntegrationTest {
final ActionStatus actionStatusMessage3 = new ActionStatus(savedAction, Action.Status.FINISHED,
System.currentTimeMillis());
actionStatusMessage3.addMessage("finish");
savedAction = controllerManagament.addUpdateActionStatus(actionStatusMessage3, savedAction);
controllerManagament.addUpdateActionStatus(actionStatusMessage3, savedAction);
targetManagement.findTargetByControllerID("Rabbit").getTargetInfo().getUpdateStatus();

View File

@@ -44,15 +44,12 @@ import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
/**
* {@link SoftwareManagement} test focused on {@link DistributionSet} and
* {@link DistributionSetType} related stuff.
*
*
* {@link DistributionSetManagement} tests.
*
*/
@Features("Component Tests - Repository")
@Stories("Software Management")
public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
@Stories("DistributionSet Management")
public class DistributionSetManagementTest extends AbstractIntegrationTest {
@Test
@Description("Tests the successfull module update of unused distribution set type which is in fact allowed.")
@@ -159,8 +156,6 @@ public class SoftwareManagementForDSTest extends AbstractIntegrationTest {
assertThat(distributionSetManagement.findDistributionSetTypeByKey("softdeleted").isDeleted()).isEqualTo(true);
}
// TODO: kzimmerm: test N+1
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that it is not possible to create a DS that already exists (unique constraint is on name,version for DS).")
public void createDuplicateDistributionSetsFailsWithException() {

View File

@@ -10,9 +10,11 @@ package org.eclipse.hawkbit.repository;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.TestDataUtil;
@@ -20,9 +22,11 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilte
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
@@ -158,6 +162,98 @@ public class TagManagementTest extends AbstractIntegrationTest {
return new DistributionSetFilterBuilder();
}
@Test
@Description("Verifies the toogle mechanism by means on assigning tag if at least on DS in the list does not have"
+ "the tag yet. Unassign if all of them have the tag already.")
public void assignAndUnassignDistributionSetTags() {
final List<DistributionSet> groupA = TestDataUtil.generateDistributionSets(20, softwareManagement,
distributionSetManagement);
final List<DistributionSet> groupB = TestDataUtil.generateDistributionSets("unassigned", 20, softwareManagement,
distributionSetManagement);
final DistributionSetTag tag = tagManagement
.createDistributionSetTag(new DistributionSetTag("tag1", "tagdesc1", ""));
// toggle A only -> A is now assigned
DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(groupA, tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
groupA.stream().map(set -> set.getId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedDs()).isEmpty();
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
// toggle A+B -> A is still assigned and B is assigned as well
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
groupB.stream().map(set -> set.getId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedDs()).isEmpty();
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
// toggle A+B -> both unassigned
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(0);
assertThat(result.getAssignedDs()).isEmpty();
assertThat(result.getUnassigned()).isEqualTo(40);
assertThat(result.getUnassignedDs()).containsAll(distributionSetManagement.findDistributionSetListWithDetails(
concat(groupB, groupA).stream().map(set -> set.getId()).collect(Collectors.toList())));
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
}
@Test
@Description("Verifies the toogle mechanism by means on assigning tag if at least on target in the list does not have"
+ "the tag yet. Unassign if all of them have the tag already.")
public void assignAndUnassignTargetTags() {
final List<Target> groupA = targetManagement.createTargets(TestDataUtil.generateTargets(20, ""));
final List<Target> groupB = targetManagement.createTargets(TestDataUtil.generateTargets(20, "groupb"));
final TargetTag tag = tagManagement.createTargetTag(new TargetTag("tag1", "tagdesc1", ""));
// toggle A only -> A is now assigned
TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(groupA, tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedTargets()).isEmpty();
assertThat(result.getTargetTag()).isEqualTo(tag);
// toggle A+B -> A is still assigned and B is assigned as well
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedTargets()).isEmpty();
assertThat(result.getTargetTag()).isEqualTo(tag);
// toggle A+B -> both unassigned
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(0);
assertThat(result.getAssignedTargets()).isEmpty();
assertThat(result.getUnassigned()).isEqualTo(40);
assertThat(result.getUnassignedTargets()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
concat(groupB, groupA).stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getTargetTag()).isEqualTo(tag);
}
@SafeVarargs
private final <T> List<T> concat(final List<T>... targets) {
final List<T> result = new ArrayList<>();
Arrays.asList(targets).forEach(result::addAll);
return result;
}
@Test
@Description("Ensures that all tags are retrieved through repository.")
public void findAllTargetTags() {
@@ -266,48 +362,38 @@ public class TagManagementTest extends AbstractIntegrationTest {
}
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
public void failedDuplicateTargetTagNameException() {
tagManagement.createTargetTag(new TargetTag("A"));
try {
tagManagement.createTargetTag(new TargetTag("A"));
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
tagManagement.createTargetTag(new TargetTag("A"));
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
tagManagement.createTargetTag(new TargetTag("A"));
final TargetTag tag = tagManagement.createTargetTag(new TargetTag("B"));
tag.setName("A");
try {
tagManagement.updateTargetTag(tag);
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
tagManagement.updateTargetTag(tag);
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
public void failedDuplicateDsTagNameException() {
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
try {
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("B"));
tag.setName("A");
try {
tagManagement.updateDistributionSetTag(tag);
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
tagManagement.updateDistributionSetTag(tag);
}
@Test