@Test public void testGetObjectFromNameClassPair() throws NamingException { Object expectedObject = "object"; Object expectedResult = "result"; Binding expectedBinding = new Binding("some name", expectedObject); when(mapperMock.mapFromContext(expectedObject)).thenReturn(expectedResult); Object actualResult = tested.getObjectFromNameClassPair(expectedBinding); assertThat(actualResult).isEqualTo(expectedResult); }
public T getObjectFromNameClassPair(final NameClassPair nameClassPair) throws NamingException{ if (!(nameClassPair instanceof Binding)) { throw new IllegalArgumentException("Parameter must be an instance of Binding"); } Binding binding = (Binding) nameClassPair; Object object = binding.getObject(); if (object == null) { throw new ObjectRetrievalException("Binding did not contain any object."); } T result; if (nameClassPair instanceof HasControls) { result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair); } else { result = mapper.mapFromContext(object); } return result; }
ContextMapperCallbackHandlerWithControls extends ContextMapperCallbackHandler<T> { public T getObjectFromNameClassPair(final NameClassPair nameClassPair) throws NamingException{ if (!(nameClassPair instanceof Binding)) { throw new IllegalArgumentException("Parameter must be an instance of Binding"); } Binding binding = (Binding) nameClassPair; Object object = binding.getObject(); if (object == null) { throw new ObjectRetrievalException("Binding did not contain any object."); } T result; if (nameClassPair instanceof HasControls) { result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair); } else { result = mapper.mapFromContext(object); } return result; } }
ContextMapperCallbackHandlerWithControls extends ContextMapperCallbackHandler<T> { public T getObjectFromNameClassPair(final NameClassPair nameClassPair) throws NamingException{ if (!(nameClassPair instanceof Binding)) { throw new IllegalArgumentException("Parameter must be an instance of Binding"); } Binding binding = (Binding) nameClassPair; Object object = binding.getObject(); if (object == null) { throw new ObjectRetrievalException("Binding did not contain any object."); } T result; if (nameClassPair instanceof HasControls) { result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair); } else { result = mapper.mapFromContext(object); } return result; } ContextMapperCallbackHandlerWithControls(final ContextMapperWithControls<T> mapper); }
ContextMapperCallbackHandlerWithControls extends ContextMapperCallbackHandler<T> { public T getObjectFromNameClassPair(final NameClassPair nameClassPair) throws NamingException{ if (!(nameClassPair instanceof Binding)) { throw new IllegalArgumentException("Parameter must be an instance of Binding"); } Binding binding = (Binding) nameClassPair; Object object = binding.getObject(); if (object == null) { throw new ObjectRetrievalException("Binding did not contain any object."); } T result; if (nameClassPair instanceof HasControls) { result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair); } else { result = mapper.mapFromContext(object); } return result; } ContextMapperCallbackHandlerWithControls(final ContextMapperWithControls<T> mapper); T getObjectFromNameClassPair(final NameClassPair nameClassPair); }
ContextMapperCallbackHandlerWithControls extends ContextMapperCallbackHandler<T> { public T getObjectFromNameClassPair(final NameClassPair nameClassPair) throws NamingException{ if (!(nameClassPair instanceof Binding)) { throw new IllegalArgumentException("Parameter must be an instance of Binding"); } Binding binding = (Binding) nameClassPair; Object object = binding.getObject(); if (object == null) { throw new ObjectRetrievalException("Binding did not contain any object."); } T result; if (nameClassPair instanceof HasControls) { result = mapper.mapFromContextWithControls(object, (HasControls) nameClassPair); } else { result = mapper.mapFromContext(object); } return result; } ContextMapperCallbackHandlerWithControls(final ContextMapperWithControls<T> mapper); T getObjectFromNameClassPair(final NameClassPair nameClassPair);  }