congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Properties.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
uk.gov.gchq.gaffer.data.element.Properties
constructor

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

origin: gchq/Gaffer

Element(final String group, final Properties properties) {
  this.group = group;
  if (null == properties) {
    this.properties = new Properties();
  } else {
    this.properties = properties;
  }
}
origin: gchq/Gaffer

Element(final String group) {
  this(group, new Properties());
}
origin: gchq/Gaffer

@Override
public Properties clone() {
  return new Properties((Map<String, Object>) super.clone());
}
origin: gchq/Gaffer

@Override
public Edge emptyClone() {
  return new Edge(
      getGroup(),
      getSource(),
      getDestination(),
      isDirected(),
      getMatchedVertex(),
      new Properties()
  );
}
origin: gchq/Gaffer

@Test
public void shouldConstructEmptyProperties() {
  // Given
  // When
  final Properties properties = new Properties();
  // Then
  assertTrue(properties.isEmpty());
}
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 shouldNotAddPropertyIfPropertyNameIsNull() {
  // When
  final Properties properties = new Properties();
  properties.put(null, "propertyValue1");
  // Then
  assertEquals(0, properties.size());
}
origin: gchq/Gaffer

  @Test
  public void shouldReturnHumanReadableToString() {
    // 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 String toString = properties.toString();

    // Then
    assertTrue(toString.contains("property 2="
        + "<java.lang.String>property value 2"));
    assertTrue(toString.contains("property 1="
        + "<java.lang.String>property value 1"));
  }
}
origin: gchq/Gaffer

@Test
public void shouldNotLoadPropertyWhenLoaded() {
  // Given
  final ElementValueLoader elementLoader = mock(ElementValueLoader.class);
  final String propertyName = "property name";
  final String exceptedPropertyValue = "property value";
  final Properties properties = new Properties(propertyName, exceptedPropertyValue);
  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);
  verify(elementLoader, never()).getProperty(propertyName, lazyProperties);
}
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 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 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 shouldSerialiseAndDeserialiseProperties() throws SerialisationException {
  // Given
  final Element element = newElement("group");
  final Properties properties = new Properties();
  properties.put("property1", 1L);
  properties.put("property2", 2);
  properties.put("property3", (double) 3);
  properties.put("property4", "4");
  properties.put("property5", new Date(5L));
  element.setProperties(properties);
  // When
  final byte[] serialisedElement = JSONSerialiser.serialise(element);
  final Element deserialisedElement = JSONSerialiser.deserialise(serialisedElement, element.getClass());
  // Then
  assertTrue(StringUtil.toString(serialisedElement).contains("{\"java.util.Date\":5}"));
  assertEquals(element, deserialisedElement);
}
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 shouldCopyProperties() {
  // Given
  final Element element1 = newElement("group");
  final Properties newProperties = new Properties("property1", "propertyValue1");
  // When
  element1.copyProperties(newProperties);
  // Then
  assertEquals(1, element1.getProperties().size());
  assertEquals("propertyValue1", element1.getProperty("property1"));
}
origin: gchq/Gaffer

@Test
public void shouldSetAndGetFields() {
  // Given
  final String group = "group";
  final Properties properties = new Properties();
  final Element element = newElement();
  // When
  element.setGroup(group);
  element.setProperties(properties);
  // Then
  assertEquals(group, element.getGroup());
  assertSame(properties, element.getProperties());
}
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));
}
uk.gov.gchq.gaffer.data.elementProperties<init>

Popular methods of Properties

  • get
  • 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

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSupportFragmentManager (FragmentActivity)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Notification (javax.management)
  • Runner (org.openjdk.jmh.runner)
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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