@Test public void testRemoveProperty() { final DummyProcessor proc = new DummyProcessor(); final MockProcessContext context = new MockProcessContext(proc); context.setProperty(DummyProcessor.REQUIRED_PROP, "req-value"); context.setProperty(DummyProcessor.OPTIONAL_PROP, "opt-value"); context.setProperty(DummyProcessor.DEFAULTED_PROP, "custom-value"); assertEquals(1, proc.getUpdateCount(DummyProcessor.REQUIRED_PROP)); assertEquals(1, proc.getUpdateCount(DummyProcessor.OPTIONAL_PROP)); assertEquals(1, proc.getUpdateCount(DummyProcessor.DEFAULTED_PROP)); assertTrue(context.removeProperty(DummyProcessor.OPTIONAL_PROP)); assertNull(context.getProperty(DummyProcessor.OPTIONAL_PROP).getValue()); assertFalse(context.removeProperty(DummyProcessor.OPTIONAL_PROP)); assertEquals(2, proc.getUpdateCount(DummyProcessor.OPTIONAL_PROP)); assertTrue(context.removeProperty(DummyProcessor.REQUIRED_PROP)); assertNull(context.getProperty(DummyProcessor.REQUIRED_PROP).getValue()); assertFalse(context.removeProperty(DummyProcessor.REQUIRED_PROP)); assertEquals(2, proc.getUpdateCount(DummyProcessor.REQUIRED_PROP)); assertTrue(context.removeProperty(DummyProcessor.DEFAULTED_PROP)); assertEquals("default-value", context.getProperty(DummyProcessor.DEFAULTED_PROP).getValue()); assertFalse(context.removeProperty(DummyProcessor.DEFAULTED_PROP)); assertEquals(2, proc.getUpdateCount(DummyProcessor.DEFAULTED_PROP)); context.setProperty(DummyProcessor.DEFAULTED_PROP, DummyProcessor.DEFAULTED_PROP.getDefaultValue()); assertEquals(2, proc.getUpdateCount(DummyProcessor.DEFAULTED_PROP)); assertEquals("default-value", context.getProperty(DummyProcessor.DEFAULTED_PROP).getValue()); assertTrue(context.removeProperty(DummyProcessor.DEFAULTED_PROP)); assertEquals(2, proc.getUpdateCount(DummyProcessor.DEFAULTED_PROP)); }
public boolean removeProperty(final PropertyDescriptor descriptor) { Objects.requireNonNull(descriptor); final PropertyDescriptor fullyPopulatedDescriptor = component.getPropertyDescriptor(descriptor.getName()); String value = null; if ((value = properties.remove(fullyPopulatedDescriptor)) != null) { if (!value.equals(fullyPopulatedDescriptor.getDefaultValue())) { component.onPropertyModified(fullyPopulatedDescriptor, value, null); } return true; } return false; }
MockProcessContext extends MockControllerServiceLookup implements SchedulingContext, ControllerServiceLookup, NodeTypeProvider { public boolean removeProperty(final PropertyDescriptor descriptor) { Objects.requireNonNull(descriptor); final PropertyDescriptor fullyPopulatedDescriptor = component.getPropertyDescriptor(descriptor.getName()); String value = null; if ((value = properties.remove(fullyPopulatedDescriptor)) != null) { if (!value.equals(fullyPopulatedDescriptor.getDefaultValue())) { component.onPropertyModified(fullyPopulatedDescriptor, value, null); } return true; } return false; } }
MockProcessContext extends MockControllerServiceLookup implements SchedulingContext, ControllerServiceLookup, NodeTypeProvider { public boolean removeProperty(final PropertyDescriptor descriptor) { Objects.requireNonNull(descriptor); final PropertyDescriptor fullyPopulatedDescriptor = component.getPropertyDescriptor(descriptor.getName()); String value = null; if ((value = properties.remove(fullyPopulatedDescriptor)) != null) { if (!value.equals(fullyPopulatedDescriptor.getDefaultValue())) { component.onPropertyModified(fullyPopulatedDescriptor, value, null); } return true; } return false; } MockProcessContext(final ConfigurableComponent component);  MockProcessContext(final ConfigurableComponent component, final StateManager stateManager, final VariableRegistry variableRegistry);  MockProcessContext(final ControllerService component, final MockProcessContext context, final StateManager stateManager, final VariableRegistry variableRegistry); }
MockProcessContext extends MockControllerServiceLookup implements SchedulingContext, ControllerServiceLookup, NodeTypeProvider { public boolean removeProperty(final PropertyDescriptor descriptor) { Objects.requireNonNull(descriptor); final PropertyDescriptor fullyPopulatedDescriptor = component.getPropertyDescriptor(descriptor.getName()); String value = null; if ((value = properties.remove(fullyPopulatedDescriptor)) != null) { if (!value.equals(fullyPopulatedDescriptor.getDefaultValue())) { component.onPropertyModified(fullyPopulatedDescriptor, value, null); } return true; } return false; } MockProcessContext(final ConfigurableComponent component);  MockProcessContext(final ConfigurableComponent component, final StateManager stateManager, final VariableRegistry variableRegistry);  MockProcessContext(final ControllerService component, final MockProcessContext context, final StateManager stateManager, final VariableRegistry variableRegistry); @Override PropertyValue getProperty(final PropertyDescriptor descriptor); @Override PropertyValue getProperty(final String propertyName); @Override PropertyValue newPropertyValue(final String rawValue); ValidationResult setProperty(final String propertyName, final String propertyValue); ValidationResult setProperty(final PropertyDescriptor descriptor, final String value); boolean removeProperty(final PropertyDescriptor descriptor); @Override void yield(); boolean isYieldCalled(); void addControllerService(final String serviceIdentifier, final ControllerService controllerService, final Map<PropertyDescriptor, String> properties, final String annotationData); @Override int getMaxConcurrentTasks(); void setAnnotationData(final String annotationData); @Override String getAnnotationData(); @Override Map<PropertyDescriptor, String> getProperties(); Collection<ValidationResult> validate(); boolean isValid(); void assertValid(); @Override String encrypt(final String unencrypted); @Override String decrypt(final String encrypted); void setValidateExpressionUsage(final boolean validate); void enableExpressionValidation(); void disableExpressionValidation(); @Override ControllerServiceLookup getControllerServiceLookup(); @Override void leaseControllerService(final String identifier); @Override Set<Relationship> getAvailableRelationships(); void setUnavailableRelationships(final Set<Relationship> relationships); Set<Relationship> getUnavailableRelationships(); @Override boolean hasIncomingConnection(); void setIncomingConnection(final boolean hasIncomingConnection); @Override boolean hasConnection(Relationship relationship); void setNonLoopConnection(final boolean hasNonLoopConnection); @Override boolean hasNonLoopConnection(); void addConnection(final Relationship relationship); void removeConnection(final Relationship relationship); void setConnections(final Set<Relationship> connections); @Override boolean isExpressionLanguagePresent(final PropertyDescriptor property); @Override StateManager getStateManager(); @Override String getName(); @Override boolean isClustered(); @Override boolean isPrimary(); void setClustered(boolean clustered); void setPrimaryNode(boolean primaryNode); }
MockProcessContext extends MockControllerServiceLookup implements SchedulingContext, ControllerServiceLookup, NodeTypeProvider { public boolean removeProperty(final PropertyDescriptor descriptor) { Objects.requireNonNull(descriptor); final PropertyDescriptor fullyPopulatedDescriptor = component.getPropertyDescriptor(descriptor.getName()); String value = null; if ((value = properties.remove(fullyPopulatedDescriptor)) != null) { if (!value.equals(fullyPopulatedDescriptor.getDefaultValue())) { component.onPropertyModified(fullyPopulatedDescriptor, value, null); } return true; } return false; } MockProcessContext(final ConfigurableComponent component);  MockProcessContext(final ConfigurableComponent component, final StateManager stateManager, final VariableRegistry variableRegistry);  MockProcessContext(final ControllerService component, final MockProcessContext context, final StateManager stateManager, final VariableRegistry variableRegistry); @Override PropertyValue getProperty(final PropertyDescriptor descriptor); @Override PropertyValue getProperty(final String propertyName); @Override PropertyValue newPropertyValue(final String rawValue); ValidationResult setProperty(final String propertyName, final String propertyValue); ValidationResult setProperty(final PropertyDescriptor descriptor, final String value); boolean removeProperty(final PropertyDescriptor descriptor); @Override void yield(); boolean isYieldCalled(); void addControllerService(final String serviceIdentifier, final ControllerService controllerService, final Map<PropertyDescriptor, String> properties, final String annotationData); @Override int getMaxConcurrentTasks(); void setAnnotationData(final String annotationData); @Override String getAnnotationData(); @Override Map<PropertyDescriptor, String> getProperties(); Collection<ValidationResult> validate(); boolean isValid(); void assertValid(); @Override String encrypt(final String unencrypted); @Override String decrypt(final String encrypted); void setValidateExpressionUsage(final boolean validate); void enableExpressionValidation(); void disableExpressionValidation(); @Override ControllerServiceLookup getControllerServiceLookup(); @Override void leaseControllerService(final String identifier); @Override Set<Relationship> getAvailableRelationships(); void setUnavailableRelationships(final Set<Relationship> relationships); Set<Relationship> getUnavailableRelationships(); @Override boolean hasIncomingConnection(); void setIncomingConnection(final boolean hasIncomingConnection); @Override boolean hasConnection(Relationship relationship); void setNonLoopConnection(final boolean hasNonLoopConnection); @Override boolean hasNonLoopConnection(); void addConnection(final Relationship relationship); void removeConnection(final Relationship relationship); void setConnections(final Set<Relationship> connections); @Override boolean isExpressionLanguagePresent(final PropertyDescriptor property); @Override StateManager getStateManager(); @Override String getName(); @Override boolean isClustered(); @Override boolean isPrimary(); void setClustered(boolean clustered); void setPrimaryNode(boolean primaryNode);  }