1414 * limitations under the License.
1515 */
1616
17- package com .cedarpolicy ;
17+ package com .cedarpolicy ;
1818
1919import org .junit .jupiter .api .Test ;
2020import static org .junit .jupiter .api .Assertions .assertThrows ;
2626
2727import com .cedarpolicy .value .*;
2828import com .cedarpolicy .model .entity .Entity ;
29-
29+ import com . cedarpolicy . model . entity . Entity . InnerEntity ;
3030
3131public class EntityTests {
3232
@@ -49,4 +49,27 @@ public void getAttrTests() {
4949 // Test key not found
5050 assertEquals (principal .getAttr ("decimalAttr" ), null );
5151 }
52+
53+ @ Test
54+ public void intoInnerTests () {
55+ PrimString stringAttr = new PrimString ("stringAttrValue" );
56+ HashMap <String , Value > attrs = new HashMap <>();
57+ attrs .put ("stringAttr" , stringAttr );
58+
59+ EntityTypeName principalType = EntityTypeName .parse ("User" ).get ();
60+
61+ HashSet <EntityUID > parents = new HashSet <EntityUID >();
62+ parents .add (principalType .of ("Bob" ));
63+
64+ PrimString longTag = new PrimString ("longTagValue" );
65+ HashMap <String , Value > tags = new HashMap <>();
66+ tags .put ("tag" , longTag );
67+
68+ Entity principal = new Entity (principalType .of ("Alice" ), attrs , parents , tags );
69+ InnerEntity innerPrincipal = principal .intoInner ();
70+
71+ assertEquals (innerPrincipal .getEntityUid (), principalType .of ("Alice" ));
72+ assertEquals (innerPrincipal .getAttributes (), attrs );
73+ assertEquals (innerPrincipal .getAncestors (), parents );
74+ }
5275}
0 commit comments