Skip to content

Commit

Permalink
add test for JoinAttributeNameMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle committed May 2, 2024
1 parent 1f5b038 commit 17cf8fd
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cloudfoundry.identity.uaa.resources.jdbc;

import org.cloudfoundry.identity.uaa.resources.JoinAttributeNameMapper;
import org.cloudfoundry.identity.uaa.test.ModelTestUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -9,6 +10,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import static org.cloudfoundry.identity.uaa.util.AssertThrowsWithMessage.assertThrowsWithMessageThat;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -94,4 +96,20 @@ void invalidOperator(final String operator) {
() -> converter.getFilterValues(query, validAttributes),
is("[" + operator + "] operator is not supported."));
}
}

@Test
void testJoinFilterAttributes() {
String query = "origin eq \"origin-value\" and id eq \"group-value\"";
List<String> validAttributes = Arrays.asList("origin", "id".toLowerCase());
JoinAttributeNameMapper joinAttributeNameMapper = new JoinAttributeNameMapper("prefix");
converter.setAttributeNameMapper(joinAttributeNameMapper);
Map filterValues = converter.getFilterValues(query, validAttributes);
assertNotNull(filterValues);
assertEquals("[origin-value]", filterValues.get("origin").toString());
assertEquals("[group-value]", filterValues.get("id").toString());
assertEquals("prefix.origin", converter.map("origin"));
assertEquals("prefix.id", converter.map("id"));
assertEquals("prefix", converter.getCustomPrefix());
assertEquals("origin", joinAttributeNameMapper.mapFromInternal("prefix.origin"));
}
}

0 comments on commit 17cf8fd

Please sign in to comment.