### Question:
DialogUtils { public static boolean objectWithTheSameNameExists( SharedObjectInterface object, Collection<? extends SharedObjectInterface> scope ) { for ( SharedObjectInterface element : scope ) { String elementName = element.getName(); if ( elementName != null && elementName.equalsIgnoreCase( object.getName() ) && object != element ) { return true; } } return false; }  static String getPathOf( RepositoryElementMetaInterface object ); static boolean objectWithTheSameNameExists( SharedObjectInterface object,
      Collection<? extends SharedObjectInterface> scope ); static String getPath( String parentPath, String path );  }### Answer:
@Test public void objectWithTheSameNameExists_true_if_exists() { SharedObjectInterface sharedObject = mock( SharedObjectInterface.class ); when( sharedObject.getName() ).thenReturn( "TEST_OBJECT" ); assertTrue( objectWithTheSameNameExists( sharedObject, createTestScope( "TEST_OBJECT" ) ) ); }
@Test public void objectWithTheSameNameExists_false_if_not_exist() { SharedObjectInterface sharedObject = mock( SharedObjectInterface.class ); when( sharedObject.getName() ).thenReturn( "NEW_TEST_OBJECT" ); assertFalse( objectWithTheSameNameExists( sharedObject, createTestScope( "TEST_OBJECT" ) ) ); }
@Test public void objectWithTheSameNameExists_false_if_same_object() { SharedObjectInterface sharedObject = mock( SharedObjectInterface.class ); when( sharedObject.getName() ).thenReturn( "TEST_OBJECT" ); assertFalse( objectWithTheSameNameExists( sharedObject, Collections.singleton( sharedObject ) ) ); }