For IntelliJ IDEA,
Android Studio or Eclipse



@Test public void shouldSerializeMapWithSimpleTypes() throws Exception { MapRepresentation rep = new MapRepresentation( map( "nulls", null, "strings", "a string", "numbers", 42, "booleans", true ) ); OutputFormat format = new OutputFormat( new JsonFormat(), new URI( "http://localhost/" ), null ); String serializedMap = format.assemble( rep ); Map<String, Object> map = JsonHelper.jsonToMap( serializedMap ); assertThat( map.get( "nulls" ), is( nullValue() ) ); assertThat( map.get( "strings" ), is( "a string" ) ); assertThat( map.get( "numbers" ), is( 42 ) ); assertThat( map.get( "booleans" ), is( true ) ); }
@SuppressWarnings( "unchecked" ) private <T extends PropertyContainer> void makeSureAdditionsCanBeRead( Index<T> index, EntityCreator<T> entityCreator ) { String key = "name"; String value = "Mattias"; assertThat( index.get( key, value ).getSingle(), is( nullValue() ) ); assertThat( index.get( key, value ), emptyIterable() ); assertThat( index.query( key, "*" ), emptyIterable() ); T entity1 = entityCreator.create(); T entity2 = entityCreator.create(); index.add( entity1, key, value ); for ( int i = 0; i < 2; i++ ) { assertThat( index.get( key, value ), Contains.contains( entity1 ) ); assertThat( index.query( key, "*" ), Contains.contains( entity1 ) ); assertThat( index.get( key, value ), Contains.contains( entity1 ) ); restartTx(); } index.add( entity2, key, value ); assertThat( index.get( key, value ), Contains.contains( entity1, entity2 ) ); restartTx(); assertThat( index.get( key, value ), Contains.contains( entity1, entity2 ) ); index.delete(); }
@Test public void shouldSerializeMapWithMapsOfSimpleTypes() throws Exception { MapRepresentation rep = new MapRepresentation( map( "maps with nulls", map( "nulls", null ), "maps with strings", map( "strings", "a string" ), "maps with numbers", map( "numbers", 42 ), "maps with booleans", map( "booleans", true ) ) ); OutputFormat format = new OutputFormat( new JsonFormat(), new URI( "http://localhost/" ), null ); String serializedMap = format.assemble( rep ); Map<String, Object> map = JsonHelper.jsonToMap( serializedMap ); assertThat( ((Map) map.get( "maps with nulls" )).get( "nulls" ), is( nullValue() ) ); assertThat( ((Map) map.get( "maps with strings" )).get( "strings" ), is( "a string" ) ); assertThat( ((Map) map.get( "maps with numbers" )).get( "numbers" ), is( 42 ) ); assertThat( ((Map) map.get( "maps with booleans" )).get( "booleans" ), is( true ) ); }
@Test public void nullNewValue() { GlobalPropertyChangeHandler.PropertyChange change = GlobalPropertyChangeHandler.PropertyChange.create("favourite.java.version", null); assertThat(change.getNewValue(), nullValue()); assertThat(change.toString(), is("[key=favourite.java.version, newValue=null]")); } }
protected static void importContent( Node parent, String resourceName, int uuidBehavior ) throws RepositoryException, IOException { InputStream stream = resourceStream(resourceName); assertThat(stream, is(notNullValue())); parent.getSession().getWorkspace().importXML(parent.getPath(), stream, uuidBehavior); }
@Test public void identityWithPublicKeyCanBeRoundTripped() { // Arrange: final PublicKey publicKey = Utils.generateRandomPublicKey(); // Act: final NodeIdentity identity = createRoundTrippedIdentity(new NodeIdentity(new KeyPair(publicKey), "alice")); // Assert: Assert.assertThat(identity.getAddress().getPublicKey(), IsEqual.equalTo(publicKey)); Assert.assertThat(identity.getKeyPair().getPrivateKey(), IsNull.nullValue()); Assert.assertThat(identity.isOwned(), IsEqual.equalTo(false)); Assert.assertThat(identity.getName(), IsEqual.equalTo("alice")); }
@Test public void canCreateFacadeAroundNoCertificates() throws Exception { // Act: final URL url = new URL("http://nem.com/foo/n.jar"); final CodeSourceFacade facade = new CodeSourceFacade(new CodeSource(url, new Certificate[] {})); // Assert: Assert.assertThat(facade.getLocation(), IsEqual.equalTo(url)); Assert.assertThat(facade.getFirstCertificate(), IsNull.nullValue()); }
@Test public void schemaFactoryProperties() throws Exception { SetPropertyAnswer setPropertyAnswer = new SetPropertyAnswer(schemaFactory); doAnswer(setPropertyAnswer).when(schemaFactoryWrapper).setProperty(anyString(), anyObject()); defaultXMLSecureFactories.configureSchemaFactory(schemaFactoryWrapper); assertThat(setPropertyAnswer.exception, is(nullValue())); for (String property : SCHEMA_FACTORY_PROPERTIES) { verify(schemaFactoryWrapper).setProperty(property, ""); } }
@Test public void validatorProperties() throws Exception { SetPropertyAnswer setPropertyAnswer = new SetPropertyAnswer(schemaFactory.newSchema().newValidator()); doAnswer(setPropertyAnswer).when(validatorWrapper).setProperty(anyString(), anyObject()); defaultXMLSecureFactories.configureValidator(validatorWrapper); assertThat(setPropertyAnswer.exception, is(nullValue())); for (String property : VALIDATOR_PROPERTIES) { verify(validatorWrapper).setProperty(property, ""); } }
protected void addContentToCustomer( Session session, String pathToCustomer, String childName ) throws Exception { // Add a child under the node ... session.refresh(false); Node customer = session.getNode(pathToCustomer); Node deck = customer.addNode(childName, "acme:DeckClassType"); assertThat(deck, is(notNullValue())); }
@Test public void shouldHaveSystemBranch() throws Exception { session = createSession(); javax.jcr.Node root = session.getRootNode(); AbstractJcrNode system = (AbstractJcrNode)root.getNode("jcr:system"); assertThat(system, is(notNullValue())); }
@Test public void canParseVersionStringWithoutTag() { // Act: final NodeVersion version = NodeVersion.parse("22.1.123"); // Assert: Assert.assertThat(version.getMajorVersion(), IsEqual.equalTo(22)); Assert.assertThat(version.getMinorVersion(), IsEqual.equalTo(1)); Assert.assertThat(version.getBuildVersion(), IsEqual.equalTo(123)); Assert.assertThat(version.getTag(), IsNull.nullValue()); }
protected void startEngineAndDeployRepositoryAndLogIn() throws Exception { print("starting engine"); engine.start(); assertThat(engine.getState(), is(State.RUNNING)); print("deploying repository"); repository = engine.deploy(config); session = repository.login(); assertThat(session.getRootNode(), is(notNullValue())); }
private void registerNodeTypes( Session session, String resourcePathToCnd ) throws Exception { NodeTypeManager nodeTypes = (NodeTypeManager)session.getWorkspace().getNodeTypeManager(); URL url = getClass().getClassLoader().getResource(resourcePathToCnd); assertThat(url, is(notNullValue())); nodeTypes.registerNodeTypes(url, true); }
@Test public void testSuspendResumeTransaction() throws Exception { assertThat(tc.getTransaction(), nullValue()); Transaction tx = mock(Transaction.class); tc.bindTransaction(tx); tc.suspendCurrentTransaction(); assertNull(tc.getTransaction()); tc.resumeSuspendedTransaction(); verify(tx, times(1)).suspend(); verify(tx, times(1)).resume(); assertThat(tc.getTransaction(), is(tx)); }
@Test public void testActionBeginOrJoinAndNoTx() throws Exception { MuleTransactionConfig config = new MuleTransactionConfig(TransactionConfig.ACTION_BEGIN_OR_JOIN); ExecutionTemplate executionTemplate = createExecutionTemplate(config); config.setFactory(new TestTransactionFactory(mockTransaction)); Object result = executionTemplate.execute(getEmptyTransactionCallback()); assertThat(result, is(RETURN_VALUE)); verify(mockTransaction).commit(); verify(mockTransaction, never()).rollback(); assertThat(TransactionCoordination.getInstance().getTransaction(), IsNull.<Object>nullValue()); }
@Test public void emptyBuilder() throws Exception { MuleContext muleContext = newBuilder(new TestServicesConfigurationBuilder()).setExecutionClassloader(currentThread().getContextClassLoader()) .setClassLoaderRepository(mock(ClassLoaderRepository.class)).build().getMuleContext(); assertThat(muleContext, notNullValue()); assertThat(muleContext.isInitialised(), is(true)); muleContext.start(); assertThat(muleContext.isStarted(), is(true)); }
@Test public void shouldProvideIdentifierEvenIfNoMixinTypes() throws Exception { initializeData(); // The b node was not set up to be referenceable in this test, but does have a mixin type Node node = session.getRootNode().getNode("a").getNode("b").getNode("c"); assertThat(node.getIdentifier(), is(notNullValue())); }
private static void canDeserializeVerifiableBlock(final Block originalBlock, final int expectedType) { // Arrange: final Deserializer deserializer = Utils.roundtripVerifiableEntity(originalBlock, new MockAccountLookup()); // Act: final Block block = BlockFactory.VERIFIABLE.deserialize(deserializer); // Assert: Assert.assertThat(block, IsInstanceOf.instanceOf(Block.class)); Assert.assertThat(block.getType(), IsEqual.equalTo(expectedType)); Assert.assertThat(block.getSignature(), IsNull.notNullValue()); }
@Test public void shouldSetOptionToValue() { // When final GetAllElements op = new GetAllElements.Builder() .option("key", "value") .build(); // Then assertThat(op.getOptions(), is(notNullValue())); assertThat(op.getOptions().get("key"), is("value")); }