/
ModifyAclEntrySubstitutionStrategyTest.java
64 lines (52 loc) · 2.74 KB
/
ModifyAclEntrySubstitutionStrategyTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (c) 2017 Bosch Software Innovations GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/index.php
*
* Contributors:
* Bosch Software Innovations GmbH - initial contribution
*/
package org.eclipse.ditto.services.concierge.enforcement.placeholders.strategies;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;
import org.eclipse.ditto.model.base.auth.AuthorizationSubject;
import org.eclipse.ditto.model.base.headers.WithDittoHeaders;
import org.eclipse.ditto.model.things.AclEntry;
import org.eclipse.ditto.signals.commands.things.modify.ModifyAclEntry;
import org.junit.Test;
/**
* Tests {@link ModifyAclEntrySubstitutionStrategy} in context of
* {@link org.eclipse.ditto.services.concierge.enforcement.placeholders.PlaceholderSubstitution}.
*/
public class ModifyAclEntrySubstitutionStrategyTest extends AbstractSubstitutionStrategyTestBase {
@Override
public void assertImmutability() {
assertInstancesOf(ModifyAclEntrySubstitutionStrategy.class, areImmutable());
}
@Test
public void applyReturnsTheSameCommandInstanceWhenNoPlaceholderIsSpecified() {
final AclEntry aclEntryWithoutPlaceholders =
AclEntry.newInstance(AuthorizationSubject.newInstance(SUBJECT_ID), ACL_PERMISSIONS);
final ModifyAclEntry commandWithoutPlaceholders = ModifyAclEntry.of(THING_ID,
aclEntryWithoutPlaceholders, DITTO_HEADERS);
final WithDittoHeaders response = applyBlocking(commandWithoutPlaceholders);
assertThat(response).isSameAs(commandWithoutPlaceholders);
}
@Test
public void applyReturnsTheReplacedCommandInstanceWhenPlaceholderIsSpecified() {
final AclEntry aclEntryWithPlaceholders =
AclEntry.newInstance(AuthorizationSubject.newInstance(SUBJECT_ID_PLACEHOLDER), ACL_PERMISSIONS);
final ModifyAclEntry commandWithPlaceholders = ModifyAclEntry.of(THING_ID,
aclEntryWithPlaceholders, DITTO_HEADERS);
final WithDittoHeaders response = applyBlocking(commandWithPlaceholders);
final AclEntry expectedAclEntryReplaced =
AclEntry.newInstance(AuthorizationSubject.newInstance(SUBJECT_ID), ACL_PERMISSIONS);
final ModifyAclEntry expectedCommandReplaced = ModifyAclEntry.of(THING_ID,
expectedAclEntryReplaced, DITTO_HEADERS);
assertThat(response).isEqualTo(expectedCommandReplaced);
}
}