[java-identity-provider] 24/51: IDP-1121 Remove concrete uses of ResolverPluginDependency.
Rod Widdowson
rdw at steadingsoftware.com
Wed Feb 6 08:42:55 EST 2019
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=dec3454d40619493b26801c7fe1234384926209b
commit dec3454d40619493b26801c7fe1234384926209b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jan 22 08:33:19 2019 +0000
IDP-1121 Remove concrete uses of ResolverPluginDependency.
https://issues.shibboleth.net/jira/browse/IDP-1121
---
.../resolver/ResolverPluginDependency.java | 2 +-
.../resolver/AbstractAttributeDefinitionTest.java | 6 +-
.../resolver/PluginDependencySupportTest.java | 108 ++-------------------
.../resolver/ResolverPluginDependencyTest.java | 84 ----------------
.../resolver/impl/AttributeResolverImplTest.java | 49 ++--------
5 files changed, 18 insertions(+), 231 deletions(-)
diff --git a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolverPluginDependency.java b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolverPluginDependency.java
index eca5ba3..2a12399 100644
--- a/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolverPluginDependency.java
+++ b/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/ResolverPluginDependency.java
@@ -35,7 +35,7 @@ import com.google.common.base.Objects;
* attributes. The dependency analysis stage is aware of this difference and relies on it.
*/
@ThreadSafe
-public class ResolverPluginDependency {
+public abstract class ResolverPluginDependency {
/** ID of the plugin that will produce the attribute. */
@Nonnull @NotEmpty private final String dependencyPluginId;
diff --git a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java
index ca59f71..d69932c 100644
--- a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java
+++ b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/AbstractAttributeDefinitionTest.java
@@ -193,7 +193,7 @@ public class AbstractAttributeDefinitionTest {
public void dependencies() throws ComponentInitializationException {
MockAttributeDefinition definition = new MockAttributeDefinition("foo", null);
- definition.setDependencies(Collections.singleton(new ResolverPluginDependency("plugin")));
+ definition.setDependencies(Collections.singleton((ResolverPluginDependency) new ResolverAttributeDefinitionDependency("plugin")));
definition.initialize();
Set<ResolverPluginDependency> depends = definition.getDependencies();
@@ -204,7 +204,7 @@ public class AbstractAttributeDefinitionTest {
definition = new MockAttributeDefinition("foo", null);
definition.setSourceAttributeId("source");
- definition.setDependencies(Collections.singleton(new ResolverPluginDependency("plugin")));
+ definition.setDependencies(Collections.singleton((ResolverPluginDependency) new ResolverAttributeDefinitionDependency("source")));
definition.initialize();
Assert.assertEquals(definition.getSourceAttributeId(), "source");
@@ -212,7 +212,7 @@ public class AbstractAttributeDefinitionTest {
depends = definition.getDependencies();
Assert.assertEquals(depends.size(), 1);
- Assert.assertEquals(depends.iterator().next().getDependencyAttributeId(), "source");
+ Assert.assertEquals(depends.iterator().next().getDependencyPluginId(), "source");
}
private void testInvalidName(@Nonnull MockAttributeDefinition attrdef) {
diff --git a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java
index de3effe..79b91a2 100644
--- a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java
+++ b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/PluginDependencySupportTest.java
@@ -99,10 +99,10 @@ public class PluginDependencySupportTest {
final AttributeResolverWorkContext workContext =
resolutionContext.getSubcontext(AttributeResolverWorkContext.class, false);
- final ResolverPluginDependency depend = new ResolverPluginDependency("connector1");
- depend.setDependencyAttributeId(ResolverTestSupport.EPE_ATTRIB_ID);
+ final ResolverDataConnectorDependency depend = new ResolverDataConnectorDependency("connector1");
+ depend.setAttributeNames(Collections.singletonList(ResolverTestSupport.EPE_ATTRIB_ID));
final List<IdPAttributeValue<?>> result =
- PluginDependencySupport.getMergedAttributeValues(workContext, Collections.singletonList(depend),
+ PluginDependencySupport.getMergedAttributeValues(workContext, Collections.singletonList((ResolverPluginDependency) depend),
ResolverTestSupport.EPE_ATTRIB_ID);
Assert.assertNotNull(result);
@@ -183,58 +183,6 @@ public class PluginDependencySupportTest {
}
- @SuppressWarnings("deprecation")
- @Test public void dataConnectorNoAttrName() {
- final AttributeResolutionContext resolutionContext =
- ResolverTestSupport.buildResolutionContext(ResolverTestSupport.buildDataConnector("connector1",
- ResolverTestSupport.buildAttribute(ResolverTestSupport.EPE_ATTRIB_ID,
- ResolverTestSupport.EPE1_VALUES), ResolverTestSupport.buildAttribute(
- ResolverTestSupport.EPA_ATTRIB_ID, ResolverTestSupport.EPA1_VALUES)));
- final AttributeResolverWorkContext workContext =
- resolutionContext.getSubcontext(AttributeResolverWorkContext.class, false);
-
- final ResolverPluginDependency depend = new ResolverPluginDependency("connector1");
- final List<IdPAttributeValue<?>> result =
- PluginDependencySupport.getMergedAttributeValues(workContext, Collections.singletonList(depend),
- ResolverTestSupport.EPE_ATTRIB_ID);
-
- Assert.assertNotNull(result);
- Assert.assertTrue(result.isEmpty());
-
- Assert.assertTrue(PluginDependencySupport.getMergedAttributeValues(workContext, Collections.singletonList(depend)).isEmpty());
- }
-
-
- @Test public void getMergedAttributeValueWithMultipleDependenciesOld() {
- final MockStaticDataConnector connector1 =
- ResolverTestSupport.buildDataConnector("connector1", ResolverTestSupport.buildAttribute(
- ResolverTestSupport.EPE_ATTRIB_ID, ResolverTestSupport.EPE1_VALUES), ResolverTestSupport
- .buildAttribute(ResolverTestSupport.EPA_ATTRIB_ID, ResolverTestSupport.EPA2_VALUES));
-
- final MockStaticAttributeDefinition definition1 =
- ResolverTestSupport.buildAttributeDefinition(ResolverTestSupport.EPA_ATTRIB_ID,
- ResolverTestSupport.EPA1_VALUES);
-
- final AttributeResolutionContext resolutionContext =
- ResolverTestSupport.buildResolutionContext(connector1, definition1);
- final AttributeResolverWorkContext workContext =
- resolutionContext.getSubcontext(AttributeResolverWorkContext.class, false);
-
- final ResolverPluginDependency depend = new ResolverPluginDependency("connector1");
- depend.setDependencyAttributeId(ResolverTestSupport.EPA_ATTRIB_ID);
- final List<IdPAttributeValue<?>> result =
- PluginDependencySupport.getMergedAttributeValues(workContext,
- Arrays.asList(depend, new ResolverPluginDependency(ResolverTestSupport.EPA_ATTRIB_ID)),
- ResolverTestSupport.EPE_ATTRIB_ID);
-
- Assert.assertNotNull(result);
- Assert.assertEquals(result.size(), 4);
- Assert.assertTrue(result.contains(new StringAttributeValue(ResolverTestSupport.EPA1_VALUES[0])));
- Assert.assertTrue(result.contains(new StringAttributeValue(ResolverTestSupport.EPA1_VALUES[1])));
- Assert.assertTrue(result.contains(new StringAttributeValue(ResolverTestSupport.EPA2_VALUES[1])));
-
- }
-
@Test public void getMergedAttributeValueWithMultipleDependencies() {
final MockStaticDataConnector connector1 =
ResolverTestSupport.buildDataConnector("connector1", ResolverTestSupport.buildAttribute(
@@ -266,44 +214,6 @@ public class PluginDependencySupportTest {
}
- @Test public void getAllAttributeValuesOld() {
- final MockStaticDataConnector connector1 =
- ResolverTestSupport.buildDataConnector("connector1", ResolverTestSupport.buildAttribute(
- ResolverTestSupport.EPE_ATTRIB_ID, ResolverTestSupport.EPE1_VALUES), ResolverTestSupport
- .buildAttribute(ResolverTestSupport.EPA_ATTRIB_ID, ResolverTestSupport.EPA2_VALUES));
-
- final MockStaticAttributeDefinition definition1 =
- ResolverTestSupport.buildAttributeDefinition(ResolverTestSupport.EPA_ATTRIB_ID,
- ResolverTestSupport.EPA1_VALUES);
-
- final AttributeResolutionContext resolutionContext =
- ResolverTestSupport.buildResolutionContext(connector1, definition1);
- final AttributeResolverWorkContext workContext =
- resolutionContext.getSubcontext(AttributeResolverWorkContext.class, false);
-
- final ResolverPluginDependency depend = new ResolverPluginDependency("connector1");
- // depend.setDependencyAttributeId(ResolverTestSupport.EPA_ATTRIB_ID);
- final Map<String, List<IdPAttributeValue<?>>> result =
- PluginDependencySupport.getAllAttributeValues(workContext,
- Arrays.asList(depend, new ResolverPluginDependency(ResolverTestSupport.EPA_ATTRIB_ID)));
-
- Assert.assertNotNull(result);
- Assert.assertEquals(result.size(), 2);
-
- List<IdPAttributeValue<?>> values = result.get(ResolverTestSupport.EPE_ATTRIB_ID);
- Assert.assertNotNull(values);
- Assert.assertEquals(values.size(), 2);
- Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPE1_VALUES[0])));
- Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPE1_VALUES[1])));
-
- values = result.get(ResolverTestSupport.EPA_ATTRIB_ID);
- Assert.assertNotNull(values);
- Assert.assertEquals(values.size(), 4);
- Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA1_VALUES[0])));
- Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA1_VALUES[1])));
- Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA2_VALUES[1])));
- }
-
@Test public void getAllAttributeValues() {
final MockStaticDataConnector connector1 =
ResolverTestSupport.buildDataConnector("connector1", ResolverTestSupport.buildAttribute(
@@ -320,11 +230,11 @@ public class PluginDependencySupportTest {
resolutionContext.getSubcontext(AttributeResolverWorkContext.class, false);
final ResolverDataConnectorDependency depend = new ResolverDataConnectorDependency("connector1");
-
depend.setAllAttributes(true);
+
final Map<String, List<IdPAttributeValue<?>>> result =
PluginDependencySupport.getAllAttributeValues(workContext,
- Arrays.asList(depend, new ResolverPluginDependency(ResolverTestSupport.EPA_ATTRIB_ID)));
+ Arrays.asList(depend, new ResolverAttributeDefinitionDependency(ResolverTestSupport.EPA_ATTRIB_ID)));
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 2);
@@ -342,7 +252,7 @@ public class PluginDependencySupportTest {
Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA1_VALUES[1])));
Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA2_VALUES[1])));
}
-
+
@Test public void getAllAttributeValuesLimited() {
final MockStaticDataConnector connector1 =
ResolverTestSupport.buildDataConnector("connector1", ResolverTestSupport.buildAttribute(
@@ -359,11 +269,11 @@ public class PluginDependencySupportTest {
resolutionContext.getSubcontext(AttributeResolverWorkContext.class, false);
final ResolverDataConnectorDependency depend = new ResolverDataConnectorDependency("connector1");
-
+
depend.setAttributeNames(Collections.singleton(ResolverTestSupport.EPA_ATTRIB_ID));
final Map<String, List<IdPAttributeValue<?>>> result =
PluginDependencySupport.getAllAttributeValues(workContext,
- Arrays.asList(depend, new ResolverPluginDependency(ResolverTestSupport.EPA_ATTRIB_ID)));
+ Arrays.asList(depend, new ResolverAttributeDefinitionDependency(ResolverTestSupport.EPA_ATTRIB_ID)));
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 1);
@@ -375,6 +285,4 @@ public class PluginDependencySupportTest {
Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA1_VALUES[1])));
Assert.assertTrue(values.contains(new StringAttributeValue(ResolverTestSupport.EPA2_VALUES[1])));
}
-
-
}
\ No newline at end of file
diff --git a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/ResolverPluginDependencyTest.java b/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/ResolverPluginDependencyTest.java
deleted file mode 100644
index 6b39d8f..0000000
--- a/idp-attribute-resolver-api/src/test/java/net/shibboleth/idp/attribute/resolver/ResolverPluginDependencyTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements. See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You under the Apache
- * License, Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.shibboleth.idp.attribute.resolver;
-
-import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/** Unit test for {@link ResolverPluginDependency}. */
-public class ResolverPluginDependencyTest {
-
- /** Tests the state of a newly instantiated object. */
- @Test public void instantiation() {
- ResolverPluginDependency dep = new ResolverPluginDependency(" foo ");
- dep.setDependencyAttributeId(" bar ");
- Assert.assertEquals(dep.getDependencyPluginId(), "foo");
- Assert.assertEquals(dep.getDependencyAttributeId(), "bar");
-
- dep = new ResolverPluginDependency("foo ");
- dep.setDependencyAttributeId( "");
- Assert.assertEquals(dep.getDependencyPluginId(), "foo");
- Assert.assertNull(dep.getDependencyAttributeId());
-
- dep = new ResolverPluginDependency("foo ");
- dep.setDependencyAttributeId(null);
- Assert.assertEquals(dep.getDependencyPluginId(), "foo");
- Assert.assertNull(dep.getDependencyAttributeId());
-
- try {
- dep = new ResolverPluginDependency(null);
- Assert.fail("able to set null dependency ID");
- } catch (ConstraintViolationException e) {
- // expected this
- }
-
- try {
- dep = new ResolverPluginDependency(" ");
- Assert.fail("able to set empty dependency ID");
- } catch (ConstraintViolationException e) {
- // expected this
- }
- }
-
- @Test public void equalsToString() {
- ResolverPluginDependency dep = new ResolverPluginDependency(" foo ");
- dep.setDependencyAttributeId(" bar ");
-
- dep.toString();
-
- Assert.assertFalse(dep.equals(null));
- Assert.assertTrue(dep.equals(dep));
- Assert.assertFalse(dep.equals(this));
-
- ResolverPluginDependency other = new ResolverPluginDependency("foo");
- other.setDependencyAttributeId("bar ");
-
- Assert.assertTrue(dep.equals(other));
- Assert.assertEquals(dep.hashCode(), other.hashCode());
-
- other = new ResolverPluginDependency(" bar ");
- other.setDependencyAttributeId(" foo");
-
- Assert.assertFalse(dep.equals(other));
- Assert.assertNotSame(dep.hashCode(), other.hashCode());
-
- }
-
-}
\ No newline at end of file
diff --git a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImplTest.java b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImplTest.java
index c3b2f87..513d0ef 100644
--- a/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImplTest.java
+++ b/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImplTest.java
@@ -245,45 +245,6 @@ public class AttributeResolverImplTest {
/** Test that resolve w/ dependencies returns the expected results. */
- @Test public void resolveWithDependenciesOld() throws Exception {
- final MockDataConnector dc1 = new MockDataConnector("dc1", (Map) null);
- dc1.initialize();
-
- final IdPAttribute attr = new IdPAttribute("test");
- attr.setValues(Arrays.asList(new StringAttributeValue("a"), new StringAttributeValue("b")));
-
- final ResolverPluginDependency dep1 = new ResolverPluginDependency("dc1");
- final MockAttributeDefinition ad1 = new MockAttributeDefinition("ad1", attr);
- ad1.setDependencies(Collections.singleton(dep1));
- ad1.initialize();
-
- final MockAttributeDefinition ad2 = new MockAttributeDefinition("ad2", attr);
-
- final ResolverPluginDependency dep2 = TestSources.makeResolverPluginDependency("ad1");
- final ResolverPluginDependency dep3 = TestSources.makeResolverPluginDependency("ad2");
- final MockAttributeDefinition ad0 = new MockAttributeDefinition("ad0", attr);
- ad0.setDependencies(new HashSet<>(Arrays.asList(dep2, dep3)));
- ad0.initialize();
-
- final LazySet<DataConnector> connectors = new LazySet<>();
- connectors.add(dc1);
-
- final LazySet<AttributeDefinition> definitions = new LazySet<>();
- definitions.add(ad0);
- definitions.add(ad1);
- definitions.add(ad2);
- ad2.initialize();
-
- final AttributeResolverImpl resolver = newAttributeResolverImpl("foo", definitions, connectors);
- resolver.initialize();
-
- final AttributeResolutionContext context = new AttributeResolutionContext();
- resolver.resolveAttributes(context);
-
- Assert.assertEquals(context.getResolvedIdPAttributes().size(), 1);
- Assert.assertEquals(context.getResolvedIdPAttributes().get("test").getValues().size(), 2);
- }
-
@Test public void resolveWithDependencies() throws Exception {
final MockDataConnector dc1 = new MockDataConnector("dc1", (Map) null);
dc1.initialize();
@@ -487,25 +448,27 @@ public class AttributeResolverImplTest {
dcfail1.setFailure(true);
dcfail1.setPropagateResolutionExceptions(false);
dcfail1.initialize();
- final ResolverPluginDependency depFail1 = new ResolverPluginDependency("failer1");
+ final ResolverDataConnectorDependency depFail1 = new ResolverDataConnectorDependency("failer1");
+ depFail1.setAllAttributes(true);
final MockDataConnector dcfail2 = new MockDataConnector("failer2", new HashMap<String, IdPAttribute>());
dcfail2.setFailure(true);
dcfail2.setFailoverDataConnectorId("failer1");
dcfail2.initialize();
- final ResolverPluginDependency depFail2 = new ResolverPluginDependency("failer2");
+ final ResolverDataConnectorDependency depFail2 = new ResolverDataConnectorDependency("failer2");
+ depFail2.setAllAttributes(true);
connectors = new LazySet<>();
connectors.add(dcfail1);
connectors.add(dcfail2);
final MockAttributeDefinition ad10 = new MockAttributeDefinition("ad10", new IdPAttribute("ten"));
- ad10.setDependencies(Collections.singleton(depFail1));
+ ad10.setDependencies(Collections.singleton((ResolverPluginDependency) depFail1));
ad10.setPropagateResolutionExceptions(false);
ad10.initialize();
final MockAttributeDefinition ad11 = new MockAttributeDefinition("ad11", new IdPAttribute("eleven"));
- ad11.setDependencies(Collections.singleton(depFail2));
+ ad11.setDependencies(Collections.singleton((ResolverPluginDependency) depFail2));
ad11.setPropagateResolutionExceptions(false);
ad11.initialize();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list