@Test
  public void endTransactionInteractsWithObjectStore() throws Exception {
    // setup
    context.ignoring(mockPersistenceSession);

    context.checking(
        new Expectations() {
          {
            final Sequence transactionOrdering = context.sequence("transactionOrdering");
            oneOf(mockObjectStore).startTransaction();
            inSequence(transactionOrdering);

            // flushed twice, once before publishing, once after
            exactly(3)
                .of(mockObjectStore)
                .execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
            inSequence(transactionOrdering);

            oneOf(mockObjectStore).endTransaction();
            inSequence(transactionOrdering);
          }
        });

    transactionManager.startTransaction();
    transactionManager.endTransaction();
  }
Ejemplo n.º 2
0
  @Test
  public void unmarshal() throws Exception {
    context.checking(
        new Expectations() {

          {
            one(mockOidMarshaller).unmarshal(oidStr, RootOid.class);
            will(returnValue(oid));
          }
        });
    assertEquals(oid, keyCreatorDefault.unmarshal(oidStr));
  }
 private <T extends Facet> T mockFacetIgnoring(final Class<T> typeToMock) {
   final T facet = context.mock(typeToMock);
   context.checking(
       new Expectations() {
         {
           allowing(facet).facetType();
           will(returnValue(typeToMock));
           ignoring(facet);
         }
       });
   return facet;
 }
  @Test
  public void startTransactionInteractsWithObjectStore() throws Exception {
    // setup
    context.ignoring(mockPersistenceSession);

    context.checking(
        new Expectations() {
          {
            one(mockObjectStore).startTransaction();
          }
        });
    transactionManager.startTransaction();
  }
Ejemplo n.º 5
0
  @Before
  public void setUp() throws Exception {
    org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);

    configuration = new IsisConfigurationDefault();
    servicesList = Collections.emptyList();

    oidMarshaller = new OidMarshaller();

    context.checking(
        new Expectations() {
          {
            ignoring(mockSpecificationLoader);
            ignoring(mockPersistenceSessionFactory);

            one(mockUserProfileLoader).getProfile(with(any(AuthenticationSession.class)));
            will(returnValue(new UserProfile()));

            ignoring(mockTemplateImageLoader);
            ignoring(mockAuthenticationManager);
            ignoring(mockAuthorizationManager);
          }
        });

    final ViewFactory subviewSpec =
        new ViewFactory() {
          @Override
          public View createView(final Content content, final Axes axes, final int fieldNumber) {
            return new DummyView();
          }
        };

    final IsisSessionFactoryDefault sessionFactory =
        new IsisSessionFactoryDefault(
            DeploymentType.EXPLORATION,
            configuration,
            mockTemplateImageLoader,
            mockSpecificationLoader,
            mockAuthenticationManager,
            mockAuthorizationManager,
            mockUserProfileLoader,
            mockPersistenceSessionFactory,
            servicesList,
            oidMarshaller);

    IsisContext.setConfiguration(sessionFactory.getConfiguration());
    IsisContextStatic.createRelaxedInstance(sessionFactory);
    IsisContextStatic.openSession(new ExplorationSession());

    builder = new ActionFieldBuilder(subviewSpec);
  }
Ejemplo n.º 6
0
 @Test
 public void specification() throws Exception {
   context.checking(
       new Expectations() {
         {
           one(mockOidMarshaller).unmarshal(oidStr, TypedOid.class);
           will(returnValue(oid));
           one(mockSpecificationLoader).lookupBySpecId(oid.getObjectSpecId());
           will(returnValue(mockSpecification));
         }
       });
   final ObjectSpecification spec = keyCreatorDefault.specificationFromOidStr(oidStr);
   assertEquals(mockSpecification, spec);
 }
 @Before
 public void setUp() throws Exception {
   context.checking(
       new Expectations() {
         {
           allowing(settings).getDatePattern();
           will(returnValue("yyyy-MM-dd"));
           allowing(settings).getDateTimePattern();
           will(returnValue("yyyy-MM-dd HH:mm"));
           allowing(settings).getDatePickerPattern();
           will(returnValue("yy-mm-dd"));
         }
       });
 }
  @Test
  public void endTransactionCommitsTransactionWhenLevelDecrementsDownToZero() throws Exception {
    // setup
    context.ignoring(mockObjectStore);
    transactionManager.startTransaction();

    context.checking(
        new Expectations() {
          {
            oneOf(mockPersistenceSession).objectChangedAllDirty();
          }
        });
    assertThat(transactionManager.getTransactionLevel(), is(1));
    transactionManager.endTransaction();
    assertThat(transactionManager.getTransactionLevel(), is(0));
  }
Ejemplo n.º 9
0
 @Before
 public void setup() {
   context.checking(
       new Expectations() {
         {
           allowing(mockTax)
               .percentageFor(with(anyOf(aNull(LocalDate.class), any(LocalDate.class))));
           will(returnValue(new BigDecimal("17.5")));
         }
       });
   invoiceItem =
       new InvoiceItem() {
         public ApplicationTenancy getApplicationTenancy() {
           return null;
         }
       };
   invoiceItem.setTax(mockTax);
 }
Ejemplo n.º 10
0
  @Test
  public void test() {
    // given
    assertThat(property.getLocation(), is(nullValue()));

    // when
    final Location location = new Location();
    context.checking(
        new Expectations() {
          {
            oneOf(mockLocationLookupService).lookup("Buckingham Palace, London");
            will(returnValue(location));
          }
        });

    property.lookupLocation("Buckingham Palace, London");

    // then
    assertThat(property.getLocation(), is(location));
  }
  @Before
  public void setUpTransactionManager() throws Exception {
    context.checking(
        new Expectations() {
          {
            allowing(mockAuthenticationSession).getUserName();
            will(returnValue("sven"));

            allowing(mockAuthenticationSession).getMessageBroker();
            will(returnValue(mockMessageBroker));
          }
        });

    transactionManager =
        new IsisTransactionManager(
            mockPersistenceSession, mockObjectStore, new ServicesInjectorDefault()) {
          @Override
          public AuthenticationSession getAuthenticationSession() {
            return mockAuthenticationSession;
          }
        };
  }