Tabnine Logo
Properties.get
Code IndexAdd Tabnine to your IDE (free)

How to use
get
method
in
uk.gov.gchq.gaffer.data.element.Properties

Best Java code snippets using uk.gov.gchq.gaffer.data.element.Properties.get (Showing top 20 results out of 315)

origin: gchq/Gaffer

@Override
public Object get(final String propertyName) {
  return properties.get(propertyName);
}
origin: gchq/Gaffer

public Object getProperty(final String name) {
  return properties.get(name);
}
origin: gchq/Gaffer

public Object get(final String name) {
  final Object value;
  if (loadedProperties.contains(name)) {
    value = properties.get(name);
  } else {
    value = valueLoader.getProperty(name, this);
    put(name, value);
  }
  return value;
}
origin: gchq/Gaffer

@Test
public void shouldConstructPropertiesWithOtherProperties() {
  // Given
  final Map<String, Object> otherProperties = new HashMap<>();
  otherProperties.put("propertyName", "property value");
  // When
  final Properties properties = new Properties(otherProperties);
  // Then
  assertEquals(1, properties.size());
  assertEquals("property value", properties.get("propertyName"));
}
origin: gchq/Gaffer

@Test
public void shouldAddPropertyToMapWhenAddingProperty() {
  // Given
  final ElementValueLoader elementLoader = mock(ElementValueLoader.class);
  final Properties properties = new Properties();
  final String propertyName = "property name";
  final String propertyValue = "property value";
  final LazyProperties lazyProperties = new LazyProperties(properties, elementLoader);
  given(elementLoader.getProperty(propertyName, lazyProperties)).willReturn(propertyValue);
  // When
  lazyProperties.put(propertyName, propertyValue);
  // Then
  verify(elementLoader, never()).getProperty(propertyName, lazyProperties);
  assertEquals(propertyValue, properties.get(propertyName));
}
origin: gchq/Gaffer

@Test
public void shouldConstructPropertiesWithProperty() {
  // Given
  // When
  final Properties properties = new Properties("propertyName", "property value");
  // Then
  assertEquals(1, properties.size());
  assertEquals("property value", properties.get("propertyName"));
}
origin: gchq/Gaffer

@Test
public void shouldRemovePropertyNameFromLoadedPropertiesAndMapWhenRemoveIsCalled() {
  // Given
  final ElementValueLoader elementLoader = mock(ElementValueLoader.class);
  final Properties properties = new Properties();
  final String propertyName = "property name";
  final String propertyValue = "property value";
  final LazyProperties lazyProperties = new LazyProperties(properties, elementLoader);
  given(elementLoader.getProperty(propertyName, lazyProperties)).willReturn(propertyValue);
  lazyProperties.get(propertyName); // call it to load the value.
  // When
  lazyProperties.remove(propertyName);
  lazyProperties.get(propertyName);
  // Then
  verify(elementLoader, times(2)).getProperty(propertyName, lazyProperties); // should be called twice before and after removeProperty()
  assertEquals(propertyValue, properties.get(propertyName));
}
origin: gchq/Gaffer

@Test
public void shouldClearLoadedPropertiesAndMapWhenClearIsCalled() {
  // Given
  final ElementValueLoader elementLoader = mock(ElementValueLoader.class);
  final Properties properties = new Properties();
  final String propertyName = "property name";
  final String propertyValue = "property value";
  final LazyProperties lazyProperties = new LazyProperties(properties, elementLoader);
  given(elementLoader.getProperty(propertyName, lazyProperties)).willReturn(propertyValue);
  lazyProperties.get(propertyName); // call it to load the value.
  // When
  lazyProperties.clear();
  lazyProperties.get(propertyName);
  // Then
  verify(elementLoader, times(2)).getProperty(propertyName, lazyProperties); // should be called twice before and after clear()
  assertEquals(propertyValue, properties.get(propertyName));
}
origin: gchq/Gaffer

@Test
public void shouldCloneProperties() {
  // Given
  final String property1 = "property 1";
  final String property2 = "property 2";
  final String propertyValue1 = "property value 1";
  final String propertyValue2 = "property value 2";
  final Properties properties = new Properties();
  properties.put(property1, propertyValue1);
  properties.put(property2, propertyValue2);
  // When
  final Properties clone = properties.clone();
  // Then
  assertEquals(2, clone.size());
  assertNotSame(properties, clone);
  assertEquals(propertyValue1, clone.get(property1));
  assertEquals(propertyValue2, clone.get(property2));
}
origin: gchq/Gaffer

@Test
public void shouldRemoveProperties() {
  // Given
  final String property1 = "property 1";
  final String property2 = "property 2";
  final String property3 = "property 3";
  final String property4 = "property 4";
  final String propertyValue1 = "property value 1";
  final String propertyValue2 = "property value 2";
  final String propertyValue3 = "property value 3";
  final String propertyValue4 = "property value 4";
  final Collection<String> propertiesToRemove = Arrays.asList(property2, property4);
  final Properties properties = new Properties();
  properties.put(property1, propertyValue1);
  properties.put(property2, propertyValue2);
  properties.put(property3, propertyValue3);
  properties.put(property4, propertyValue4);
  // When
  properties.remove(propertiesToRemove);
  // Then
  assertEquals(2, properties.size());
  assertEquals(propertyValue1, properties.get(property1));
  assertEquals(propertyValue3, properties.get(property3));
}
origin: gchq/Gaffer

@Test
public void shouldKeepOnlyGivenProperties() {
  // Given
  final String property1 = "property 1";
  final String property2 = "property 2";
  final String property3 = "property 3";
  final String property4 = "property 4";
  final String propertyValue1 = "property value 1";
  final String propertyValue2 = "property value 2";
  final String propertyValue3 = "property value 3";
  final String propertyValue4 = "property value 4";
  final Collection<String> propertiesToKeep = Arrays.asList(property1, property3);
  final Properties properties = new Properties();
  properties.put(property1, propertyValue1);
  properties.put(property2, propertyValue2);
  properties.put(property3, propertyValue3);
  properties.put(property4, propertyValue4);
  // When
  properties.keepOnly(propertiesToKeep);
  // Then
  assertEquals(2, properties.size());
  assertEquals(propertyValue1, properties.get(property1));
  assertEquals(propertyValue3, properties.get(property3));
}
origin: gchq/Gaffer

@Test
public void shouldRemovePropertyNameFromLoadedPropertiesAndMapWhenKeepOnlyThesePropertiesIsCalled() {
  // Given
  final ElementValueLoader elementLoader = mock(ElementValueLoader.class);
  final Properties properties = new Properties();
  final String propertyName1 = "property name1";
  final String propertyName2 = "property name2";
  final String propertyValue1 = "property value1";
  final String propertyValue2 = "property value2";
  final LazyProperties lazyProperties = new LazyProperties(properties, elementLoader);
  given(elementLoader.getProperty(propertyName1, lazyProperties)).willReturn(propertyValue1);
  given(elementLoader.getProperty(propertyName2, lazyProperties)).willReturn(propertyValue2);
  lazyProperties.get(propertyName1); // call it to load value 1.
  lazyProperties.get(propertyName2); // call it to load value 2.
  // When
  lazyProperties.keepOnly(Sets.newSet(propertyName2));
  lazyProperties.get(propertyName1);
  lazyProperties.get(propertyName2);
  // Then
  verify(elementLoader, times(2)).getProperty(propertyName1, lazyProperties);
  verify(elementLoader, times(1)).getProperty(propertyName2, lazyProperties);
  assertEquals(propertyValue1, properties.get(propertyName1));
  assertEquals(propertyValue2, properties.get(propertyName2));
}
origin: gchq/Gaffer

@Test
public void shouldRemovePropertyNamesFromLoadedPropertiesAndMapWhenRemovePropertiesIsCalled() {
  // Given
  final ElementValueLoader elementLoader = mock(ElementValueLoader.class);
  final Properties properties = new Properties();
  final String propertyName1 = "property name1";
  final String propertyName2 = "property name2";
  final String propertyValue1 = "property value1";
  final String propertyValue2 = "property value2";
  final LazyProperties lazyProperties = new LazyProperties(properties, elementLoader);
  given(elementLoader.getProperty(propertyName1, lazyProperties)).willReturn(propertyValue1);
  given(elementLoader.getProperty(propertyName2, lazyProperties)).willReturn(propertyValue2);
  lazyProperties.get(propertyName1); // call it to load value 1.
  lazyProperties.get(propertyName2); // call it to load value 2.
  // When
  lazyProperties.remove(Sets.newSet(propertyName1));
  lazyProperties.get(propertyName1);
  lazyProperties.get(propertyName2);
  // Then
  verify(elementLoader, times(2)).getProperty(propertyName1, lazyProperties);
  verify(elementLoader, times(1)).getProperty(propertyName2, lazyProperties);
  assertEquals(propertyValue1, properties.get(propertyName1));
  assertEquals(propertyValue2, properties.get(propertyName2));
}
origin: gchq/Gaffer

@Test
public void shouldLoadPropertyWhenNotLoaded() {
  // Given
  final ElementValueLoader elementLoader = mock(ElementValueLoader.class);
  final Properties properties = new Properties();
  final String propertyName = "property name";
  final String exceptedPropertyValue = "property value";
  final LazyProperties lazyProperties = new LazyProperties(properties, elementLoader);
  given(elementLoader.getProperty(propertyName, lazyProperties)).willReturn(exceptedPropertyValue);
  // When
  final Object propertyValue = lazyProperties.get(propertyName);
  // Then
  assertEquals(exceptedPropertyValue, propertyValue);
  assertEquals(propertyValue, properties.get(propertyName));
}
origin: gchq/Gaffer

@Test
public void shouldRemovePropertyIfAddedWithNullValue() {
  // Given
  final Properties properties = new Properties();
  properties.put("property1", "propertyValue1");
  properties.put("property2", "propertyValue2");
  // When
  properties.put("property1", null);
  // Then
  assertEquals(1, properties.size());
  assertEquals(null, properties.get("property1"));
}
origin: gchq/Gaffer

@Test
public void shouldAggregateProperties() {
  // Given
  final String reference = "reference1";
  final Integer value1 = 1;
  final Integer value2 = 2;
  final Integer valueResult = 3;
  final BinaryOperator<Integer> function = mock(BinaryOperator.class);
  given(function.apply(value1, value2)).willReturn(valueResult);
  final ElementAggregator aggregator = new ElementAggregator.Builder()
      .select(reference)
      .execute(function)
      .build();
  final Properties properties1 = new Properties(reference, value1);
  final Properties properties2 = new Properties(reference, value2);
  // When
  final Properties result = aggregator.apply(properties1, properties2);
  // Then
  assertEquals(valueResult, result.get(reference));
}
origin: gchq/Gaffer

@Test
public void shouldNotRemovePropertiesWhenNoRelevantExcludeProperties() {
  //Given
  final View view = new View.Builder()
      .edge(TestGroups.EDGE, new ViewElementDefinition.Builder()
          .excludeProperties(TestPropertyNames.COUNT)
          .build())
      .entity(TestGroups.ENTITY, new ViewElementDefinition.Builder()
          .properties(TestPropertyNames.PROP_2)
          .build())
      .build();
  final Edge edge = new Edge.Builder()
      .group(TestGroups.EDGE)
      .property(TestPropertyNames.PROP_1, "1")
      .property(TestPropertyNames.PROP_2, "2")
      .property(TestPropertyNames.PROP_3, "3")
      .build();
  //When
  ViewUtil.removeProperties(view, edge);
  //Then
  assertEquals(3, edge.getProperties().size());
  assertEquals("1", edge.getProperties().get(TestPropertyNames.PROP_1));
  assertEquals("2", edge.getProperties().get(TestPropertyNames.PROP_2));
  assertEquals("3", edge.getProperties().get(TestPropertyNames.PROP_3));
}
origin: gchq/Gaffer

@Test
public void shouldNotRemovePropertiesWhenNotSet() {
  //Given
  final View view = new View.Builder()
      .edge(TestGroups.EDGE, new ViewElementDefinition.Builder()
          .allProperties()
          .build())
      .entity(TestGroups.ENTITY, new ViewElementDefinition.Builder()
          .properties(TestPropertyNames.PROP_2)
          .build())
      .build();
  final Edge edge = new Edge.Builder()
      .group(TestGroups.EDGE)
      .property(TestPropertyNames.PROP_1, "1")
      .property(TestPropertyNames.PROP_2, "2")
      .property(TestPropertyNames.PROP_3, "3")
      .build();
  //When
  ViewUtil.removeProperties(view, edge);
  //Then
  assertEquals(3, edge.getProperties().size());
  assertEquals("1", edge.getProperties().get(TestPropertyNames.PROP_1));
  assertEquals("2", edge.getProperties().get(TestPropertyNames.PROP_2));
  assertEquals("3", edge.getProperties().get(TestPropertyNames.PROP_3));
}
origin: gchq/Gaffer

@Test
public void shouldRemoveExcludedProperties() {
  //Given
  final View view = new View.Builder()
      .edge(TestGroups.EDGE, new ViewElementDefinition.Builder()
          .excludeProperties(TestPropertyNames.PROP_1)
          .build())
      .entity(TestGroups.ENTITY, new ViewElementDefinition.Builder()
          .excludeProperties(TestPropertyNames.PROP_2)
          .build())
      .build();
  final Edge edge = new Edge.Builder()
      .group(TestGroups.EDGE)
      .property(TestPropertyNames.PROP_1, "1")
      .property(TestPropertyNames.PROP_2, "2")
      .property(TestPropertyNames.PROP_3, "3")
      .build();
  //When
  ViewUtil.removeProperties(view, edge);
  //Then
  assertEquals(2, edge.getProperties().size());
  assertEquals("2", edge.getProperties().get(TestPropertyNames.PROP_2));
  assertEquals("3", edge.getProperties().get(TestPropertyNames.PROP_3));
}
origin: gchq/Gaffer

@Test
public void shouldKeepOnlyProvidedProperties() {
  //Given
  final View view = new View.Builder()
      .edge(TestGroups.EDGE, new ViewElementDefinition.Builder()
          .properties(TestPropertyNames.PROP_1)
          .build())
      .entity(TestGroups.ENTITY, new ViewElementDefinition.Builder()
          .properties(TestPropertyNames.PROP_2)
          .build())
      .build();
  final Edge edge = new Edge.Builder()
      .group(TestGroups.EDGE)
      .property(TestPropertyNames.PROP_1, "1")
      .property(TestPropertyNames.PROP_2, "2")
      .property(TestPropertyNames.PROP_3, "3")
      .build();
  //When
  ViewUtil.removeProperties(view, edge);
  //Then
  assertEquals(1, edge.getProperties().size());
  assertEquals("1", edge.getProperties().get(TestPropertyNames.PROP_1));
}
uk.gov.gchq.gaffer.data.elementPropertiesget

Popular methods of Properties

  • <init>
  • put
  • remove
  • clone
  • entrySet
  • isEmpty
  • keepOnly
    Removes all properties with names that are not in the provided set.
  • keySet
  • putAll
  • size
  • clear
  • containsKey
  • clear,
  • containsKey,
  • containsValue,
  • equals,
  • hashCode,
  • toString,
  • values

Popular in Java

  • Making http requests using okhttp
  • addToBackStack (FragmentTransaction)
  • setRequestProperty (URLConnection)
  • notifyDataSetChanged (ArrayAdapter)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now