@Test public void testExecutePLSQLBuilderWithStatement() { MockBuilder builder = new MockBuilder() { @Override public void configure() { plsql(dataSource) .statement("Test Statement") .statement("Test2 Statement") .statement("Test3 Statement"); } }; builder.run(null, null); Assert.assertEquals(builder.testCase().getActions().size(), 1); Assert.assertEquals( builder.testCase().getActions().get(0).getClass(), ExecutePLSQLAction.class); ExecutePLSQLAction action = (ExecutePLSQLAction) builder.testCase().getActions().get(0); Assert.assertEquals(action.getName(), ExecutePLSQLAction.class.getSimpleName()); Assert.assertEquals(action.isIgnoreErrors(), false); Assert.assertEquals( action.getStatements().toString(), "[Test Statement, Test2 Statement, Test3 Statement]"); Assert.assertNull(action.getScript()); Assert.assertNull(action.getSqlResourcePath()); Assert.assertEquals(action.getDataSource(), dataSource); }
@Test public void testViewCardinalities() { // SwitcherView should appear differently depending on number of views available // Multiple views -> Combo box // One view -> Label // No views -> Neither // Create the test object View switcherView = SwitcherView.VIEW_INFO.createView(mockComponent); // During normal initialization, should have two view infos. // A Combo Box should be found. Assert.assertNotNull(findComponent(switcherView, JComboBox.class)); // With only one view info, should have a label instead Mockito.when(mockComponent.getViewInfos(ViewType.OBJECT)) .thenReturn(Collections.singleton(mockViewInfo1)); switcherView = SwitcherView.VIEW_INFO.createView(mockComponent); Assert.assertNull(findComponent(switcherView, JComboBox.class)); Assert.assertNotNull(findComponent(switcherView, JLabel.class)); // With no views, there should be no label or combo box Mockito.when(mockComponent.getViewInfos(ViewType.OBJECT)) .thenReturn(Collections.<ViewInfo>emptySet()); switcherView = SwitcherView.VIEW_INFO.createView(mockComponent); Assert.assertNull(findComponent(switcherView, JComboBox.class)); Assert.assertNull(findComponent(switcherView, JLabel.class)); }
@Test public void testReplace() { Assert.assertEquals(_VALUE_1, _ehcachePortalCache.get(_KEY_1)); Assert.assertNull(_ehcachePortalCache.get(_KEY_2)); // Replace 1 Assert.assertEquals(_VALUE_1, _ehcachePortalCache.replace(_KEY_1, _VALUE_2)); Assert.assertEquals(_VALUE_2, _ehcachePortalCache.get(_KEY_1)); Assert.assertNull(_ehcachePortalCache.get(_KEY_2)); _defaultCacheListener.assertActionsCount(1); _defaultCacheListener.assertUpdated(_KEY_1, _VALUE_2); _defaultCacheListener.reset(); // Replace 2 Assert.assertNull(_ehcachePortalCache.replace(_KEY_2, _VALUE_2)); Assert.assertEquals(_VALUE_2, _ehcachePortalCache.get(_KEY_1)); Assert.assertNull(_ehcachePortalCache.get(_KEY_2)); _defaultCacheListener.assertActionsCount(0); // Replace 3 Assert.assertFalse(_ehcachePortalCache.replace(_KEY_1, _VALUE_1, _VALUE_2)); Assert.assertEquals(_VALUE_2, _ehcachePortalCache.get(_KEY_1)); Assert.assertNull(_ehcachePortalCache.get(_KEY_2)); _defaultCacheListener.assertActionsCount(0); }
@Test(dependsOnMethods = "updateCollectionsRemoveWithWhereOperator") public void updateMapsWithPutOperatorAndWhere() { ODocument doc = database .command( new OCommandSQL( "insert into cluster:default (equaledges, name, properties) values ('no', 'updateMapsWithPutOperatorAndWhere', {} )")) .execute(); Integer records = database .command( new OCommandSQL( "update " + doc.getIdentity() + " put properties = 'one', 'two' where name = 'updateMapsWithPutOperatorAndWhere'")) .execute(); Assert.assertEquals(records.intValue(), 1); ODocument loadedDoc = database.load(doc.getIdentity(), "*:-1", true); Assert.assertTrue(loadedDoc.field("properties") instanceof Map); @SuppressWarnings("unchecked") Map<Object, Object> entries = loadedDoc.field("properties"); Assert.assertEquals(entries.size(), 1); Assert.assertNull(entries.get("round")); Assert.assertNull(entries.get("blaaa")); Assert.assertEquals(entries.get("one"), "two"); }
@Test(description = "convert a model with list property") public void listPropertyTest() { final Model model = new ModelImpl() .description("a sample model") .property("id", new LongProperty()) .property("urls", new ArrayProperty().items(new StringProperty())) .required("id"); final DefaultCodegen codegen = new TypeScriptFetchClientCodegen(); final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); Assert.assertEquals(cm.classname, "Sample"); Assert.assertEquals(cm.description, "a sample model"); Assert.assertEquals(cm.vars.size(), 2); final CodegenProperty property1 = cm.vars.get(0); Assert.assertEquals(property1.baseName, "id"); Assert.assertEquals(property1.datatype, "number"); Assert.assertEquals(property1.name, "id"); Assert.assertEquals(property1.defaultValue, "null"); Assert.assertEquals(property1.baseType, "number"); Assert.assertTrue(property1.hasMore); Assert.assertTrue(property1.required); Assert.assertTrue(property1.isNotContainer); final CodegenProperty property2 = cm.vars.get(1); Assert.assertEquals(property2.baseName, "urls"); Assert.assertEquals(property2.datatype, "Array<string>"); Assert.assertEquals(property2.name, "urls"); Assert.assertEquals(property2.baseType, "Array"); Assert.assertNull(property2.hasMore); Assert.assertNull(property2.required); Assert.assertTrue(property2.isContainer); }
public void testAbstract() { final FunctionExclusionGroups groups = new AbstractFunctionExclusionGroups<String>() { @Override protected String getKey(final FunctionDefinition function) { if (function.getShortName().startsWith("A_")) { return "A"; } else if (function.getShortName().startsWith("B_")) { return "B"; } else { return null; } } }; final FunctionDefinition a_foo = new Function("A_foo"); final FunctionDefinition a_bar = new Function("A_bar"); final FunctionDefinition b_foo = new Function("B_foo"); final FunctionDefinition b_bar = new Function("B_bar"); final FunctionDefinition foo = new Function("foo"); final FunctionDefinition bar = new Function("bar"); assertNull(groups.getExclusionGroup(foo)); assertNull(groups.getExclusionGroup(bar)); final FunctionExclusionGroup afoo1 = groups.getExclusionGroup(a_foo); final FunctionExclusionGroup afoo2 = groups.getExclusionGroup(a_foo); assertEquals(afoo1, afoo2); final FunctionExclusionGroup abar = groups.getExclusionGroup(a_bar); assertEquals(abar, afoo1); final FunctionExclusionGroup bfoo = groups.getExclusionGroup(b_foo); assertNotEquals(abar, bfoo); final FunctionExclusionGroup bbar = groups.getExclusionGroup(b_bar); assertEquals(bbar, bfoo); }
@Test public void testWithAlgorithmOverrides() throws ResolverException { roleDesc .getKeyDescriptors() .add(buildKeyDescriptor(rsaCred1KeyName, UsageType.ENCRYPTION, rsaCred1.getPublicKey())); config2.setDataEncryptionAlgorithms( Collections.singletonList(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256)); config2.setKeyTransportEncryptionAlgorithms( Collections.singletonList(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15)); EncryptionParameters params = resolver.resolveSingle(criteriaSet); Assert.assertNotNull(params); Assert.assertEquals( params.getKeyTransportEncryptionCredential().getPublicKey(), rsaCred1.getPublicKey()); Assert.assertEquals( params.getKeyTransportEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15); Assert.assertNotNull(params.getKeyTransportKeyInfoGenerator()); Assert.assertNull(params.getDataEncryptionCredential()); Assert.assertEquals( params.getDataEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256); Assert.assertNull(params.getDataKeyInfoGenerator()); }
@Test public void testEncryptionMethodWithWhitelist() throws ResolverException { KeyDescriptor keyDescriptor = buildKeyDescriptor(rsaCred1KeyName, UsageType.ENCRYPTION, rsaCred1.getPublicKey()); keyDescriptor .getEncryptionMethods() .add(buildEncryptionMethod(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15)); keyDescriptor .getEncryptionMethods() .add(buildEncryptionMethod(EncryptionConstants.ALGO_ID_BLOCKCIPHER_TRIPLEDES)); roleDesc.getKeyDescriptors().add(keyDescriptor); config1.setWhitelistedAlgorithms( Arrays.asList( EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP, EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192)); EncryptionParameters params = resolver.resolveSingle(criteriaSet); Assert.assertNotNull(params); Assert.assertEquals( params.getKeyTransportEncryptionCredential().getPublicKey(), rsaCred1.getPublicKey()); Assert.assertEquals( params.getKeyTransportEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSAOAEP); Assert.assertNotNull(params.getKeyTransportKeyInfoGenerator()); Assert.assertNull(params.getDataEncryptionCredential()); Assert.assertEquals( params.getDataEncryptionAlgorithm(), EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES192); Assert.assertNull(params.getDataKeyInfoGenerator()); }
@Test public void getProductByDownloadableFilename() { fr.gael.dhus.database.object.Collection validCollection; fr.gael.dhus.database.object.Collection invalidCollection; Product product; validCollection = new Collection(); validCollection.setUUID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa3"); validCollection.setName("Japan"); invalidCollection = new Collection(); invalidCollection.setUUID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4"); invalidCollection.setName("China"); product = dao.getProductByDownloadableFilename("prod0", validCollection); Assert.assertNotNull(product); Assert.assertEquals(product.getId().intValue(), 0); product = dao.getProductByDownloadableFilename("prod6", validCollection); Assert.assertNull(product); product = dao.getProductByDownloadableFilename("prod0", invalidCollection); Assert.assertNull(product); product = dao.getProductByDownloadableFilename("prod6", null); Assert.assertNotNull(product); Assert.assertEquals(product.getId().intValue(), 6); product = dao.getProductByDownloadableFilename(null, null); Assert.assertNull(product); }
@SuppressWarnings({"rawtypes", "unchecked"}) public void testStartMonitoringWithTimeout() { ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); expect( schedulerMock.scheduleWithFixedDelay( anyObject(Runnable.class), anyLong(), anyLong(), anyObject(TimeUnit.class))) .andReturn(mockFuture); replay(mockFuture); replay(schedulerMock); AsyncMonitor<Object> monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), new EventBus()); assertNull(monitor.getFuture()); assertNull(monitor.getTimeout()); monitor.startMonitoring(100L); assertNotNull(monitor.getFuture()); assertNotNull(monitor.getTimeout()); assertTrue(monitor.getTimeout() > 100L); verify(mockFuture); verify(schedulerMock); }
public void shouldMapModelWithNullItems() { D1 result = modelMapper.map(new S1(), D1.class); assertNull(result.sub); assertEquals(result.subSomething, 0); assertNull(result.nullString); assertNull(result.longValue); }
@Test(groups = {"functional.decode", "primitives"}) public void testDecode() throws Exception { byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); LocationAreaImpl prim = new LocationAreaImpl(); prim.decodeAll(asn); assertEquals(tag, LocationAreaImpl._TAG_laiFixedLength); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); LAIFixedLength lai = prim.getLAIFixedLength(); assertEquals(lai.getMCC(), 249); assertEquals(lai.getMNC(), 1); assertEquals(lai.getLac(), 14010); assertNull(prim.getLAC()); data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new LocationAreaImpl(); prim.decodeAll(asn); assertEquals(tag, LocationAreaImpl._TAG_lac); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNull(prim.getLAIFixedLength()); LAC lac = prim.getLAC(); assertEquals(lac.getLac(), 14010); }
/** * Test for issue 106: Session not updated in memcached when only a session attribute was removed * http://code.google.com/p/memcached-session-manager/issues/detail?id=106 */ @Test(enabled = true, dataProviderClass = TestUtils.class, dataProvider = STICKYNESS_PROVIDER) public void testSessionUpdatedInMemcachedWhenSessionAttributeIsRemovedIssue106( final SessionAffinityMode sessionAffinity) throws IOException, InterruptedException, HttpException { setStickyness(sessionAffinity); final String key = "foo"; final String value = "bar"; final String sessionId1 = post(_httpClient, _portTomcat1, null, key, value).getSessionId(); assertNotNull(sessionId1, "No session created."); Response response = get(_httpClient, _portTomcat1, sessionId1); assertEquals(response.getSessionId(), sessionId1); assertEquals(response.get(key), value); final Map<String, String> params = asMap(PARAM_REMOVE, key); response = get(_httpClient, _portTomcat1, "/", sessionId1, params); assertEquals(response.getSessionId(), sessionId1); assertNull(response.get(key)); // also the next request must not include this session attribute response = get(_httpClient, _portTomcat1, sessionId1); assertEquals(response.getSessionId(), sessionId1); assertNull(response.get(key)); }
@Test public void testResultSetValidationError() { String sql = "select ORDERTYPE, STATUS from orders where ID=5"; reset(jdbcTemplate); Map<String, Object> resultMap = new HashMap<String, Object>(); resultMap.put("ORDERTYPE", "small"); resultMap.put("STATUS", "in_progress"); expect(jdbcTemplate.queryForList(sql)).andReturn(Collections.singletonList(resultMap)); replay(jdbcTemplate); List<String> stmts = Collections.singletonList(sql); executeSQLQueryAction.setStatements(stmts); Map<String, List<String>> controlResultSet = new HashMap<String, List<String>>(); controlResultSet.put( "ORDERTYPE", Collections.singletonList("xxl")); // this is supposed to cause an error controlResultSet.put("STATUS", Collections.singletonList("in_progress")); executeSQLQueryAction.setControlResultSet(controlResultSet); try { executeSQLQueryAction.execute(context); } catch (ValidationException e) { Assert.assertNull(context.getVariables().get("${ORDERTYPE}")); Assert.assertNull(context.getVariables().get("${STATUS}")); return; } Assert.fail("Expected test to fail with " + ValidationException.class + " but was successful"); }
public void testDroolsGeneration(int i) throws Exception { String filename = (i % 2 == 0) ? "/drools/stress1.drl" : "/drools/stress2.drl"; InputStreamReader reader = new InputStreamReader(DroolsKnowledgeBaseTest.class.getResourceAsStream(filename)); KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration(); aconf.setProperty("drools.agent.newInstance", "false"); aconf.setProperty("drools.agent.monitorChangeSetEvents", "false"); aconf.setProperty("drools.agent.scanResources", "false"); KnowledgeBuilder builder = compileRules(reader); KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("Success Correspondence Agent", aconf); KnowledgeBase kbase = kagent.getKnowledgeBase(); kbase.addKnowledgePackages(builder.getKnowledgePackages()); // kagent.monitorResourceChangeEvents(false); Rule rule1 = kbase.getRule("com.rosettastone.succor", "Equal rule 1"); Rule rule5 = kbase.getRule("com.rosettastone.succor", "Equal rule 5"); Rule rule6 = kbase.getRule("com.rosettastone.succor", "Equal rule 6"); StatelessKnowledgeSession session = kbase.newStatelessKnowledgeSession(); if (i % 2 == 0) { Assert.assertNotNull(rule1); Assert.assertNotNull(rule5); Assert.assertNull(rule6); testRulesFirst(session); } else { Assert.assertNull(rule1); Assert.assertNotNull(rule5); Assert.assertNotNull(rule6); testRulesSecond(session); } }
@Test public void testProduceConsumeMultiMessage() { PersistentQueue<Message> queue = new PersistentQueue<Message>("jk.store"); queue.init(); for (int i = 0; i < 10; i++) { assertTrue(queue.produce(new Message(i)), "always success"); } for (int i = 0; i < 10; i++) { Message expected = queue.consume(); Assert.assertEquals(i, expected.index(), "Comparing index value"); Assert.assertEquals( "My name is JK and I am a crap living in Singapore !@#$$%^^&&", expected.value(), "Comparing message value"); } Assert.assertNull(queue.consume(), "Already Popped, so it should not be available"); queue = new PersistentQueue<Message>("jk.store"); queue.init(); Assert.assertNull(queue.consume(), "Already Popped, so it should not be available"); //////////////// queue = new PersistentQueue<Message>("jk.store"); queue.init(); for (int i = 11; i <= 20; i++) { assertTrue(queue.produce(new Message(i)), "always success"); } for (int i = 11; i <= 20; i++) { Message expected = queue.consume(); Assert.assertEquals(i, expected.index(), "Comparing index value"); Assert.assertEquals( "My name is JK and I am a crap living in Singapore !@#$$%^^&&", expected.value(), "Comparing message value"); } }
@Test public void testWithRSAOAEPParametersFromConfig() throws ResolverException { roleDesc .getKeyDescriptors() .add(buildKeyDescriptor(rsaCred1KeyName, UsageType.ENCRYPTION, rsaCred1.getPublicKey())); config3.setRSAOAEPParameters( new RSAOAEPParameters(EncryptionConstants.ALGO_ID_DIGEST_SHA256, null, "oaep-params-3")); EncryptionParameters params = resolver.resolveSingle(criteriaSet); Assert.assertNotNull(params); Assert.assertEquals( params.getKeyTransportEncryptionCredential().getPublicKey(), rsaCred1.getPublicKey()); Assert.assertEquals(params.getKeyTransportEncryptionAlgorithm(), defaultRSAKeyTransportAlgo); Assert.assertNotNull(params.getKeyTransportKeyInfoGenerator()); Assert.assertNull(params.getDataEncryptionCredential()); Assert.assertEquals(params.getDataEncryptionAlgorithm(), defaultAES128DataAlgo); Assert.assertNull(params.getDataKeyInfoGenerator()); Assert.assertNotNull(params.getRSAOAEPParameters()); Assert.assertEquals( params.getRSAOAEPParameters().getDigestMethod(), EncryptionConstants.ALGO_ID_DIGEST_SHA256); Assert.assertNull(params.getRSAOAEPParameters().getMaskGenerationFunction()); Assert.assertEquals(params.getRSAOAEPParameters().getOAEPParams(), "oaep-params-3"); }
@SuppressWarnings({"rawtypes", "unchecked"}) public void testMonitorAndContinueWithoutTimeout() { ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); expect( schedulerMock.scheduleWithFixedDelay( anyObject(Runnable.class), anyLong(), anyLong(), anyObject(TimeUnit.class))) .andReturn(mockFuture); replay(mockFuture); replay(schedulerMock); CoutingEventHandler handler = new CoutingEventHandler(); EventBus eventBus = new EventBus(); eventBus.register(handler); AsyncMonitor<Object> monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), eventBus); assertNull(monitor.getFuture()); assertNull(monitor.getTimeout()); monitor.startMonitoring(null); assertNotNull(monitor.getFuture()); assertNull(monitor.getTimeout()); monitor.run(); assertEquals(handler.numCompletes, 0); assertEquals(handler.numFailures, 0); assertEquals(handler.numTimeouts, 0); verify(mockFuture); verify(schedulerMock); }
@Test public void testResolve() throws ResolverException { roleDesc .getKeyDescriptors() .add(buildKeyDescriptor(rsaCred1KeyName, UsageType.ENCRYPTION, rsaCred1.getPublicKey())); Iterable<EncryptionParameters> paramsIter = resolver.resolve(criteriaSet); Assert.assertNotNull(paramsIter); Iterator<EncryptionParameters> iterator = paramsIter.iterator(); Assert.assertNotNull(iterator); Assert.assertTrue(iterator.hasNext()); EncryptionParameters params = iterator.next(); Assert.assertNotNull(params); Assert.assertEquals( params.getKeyTransportEncryptionCredential().getPublicKey(), rsaCred1.getPublicKey()); Assert.assertEquals(params.getKeyTransportEncryptionAlgorithm(), defaultRSAKeyTransportAlgo); Assert.assertNotNull(params.getKeyTransportKeyInfoGenerator()); Assert.assertNull(params.getDataEncryptionCredential()); Assert.assertEquals(params.getDataEncryptionAlgorithm(), defaultAES128DataAlgo); Assert.assertNull(params.getDataKeyInfoGenerator()); Assert.assertFalse(iterator.hasNext()); }
/** * Tests. * * @throws Exception exception */ @Test public void test() throws Exception { final LinkRepository linkRepository = getLinkRepository(); final int link1Order = 1, link2Order = 2, link3Order = 3; JSONObject link1 = new JSONObject(); link1.put(Link.LINK_TITLE, "link title"); link1.put(Link.LINK_DESCRIPTION, "link description"); link1.put(Link.LINK_ADDRESS, "link address"); link1.put(Link.LINK_ORDER, link1Order); Transaction transaction = linkRepository.beginTransaction(); linkRepository.add(link1); transaction.commit(); Assert.assertNull(linkRepository.getByAddress("test")); Assert.assertNotNull(linkRepository.getByAddress("link address")); Assert.assertNull(linkRepository.getByOrder(0)); Assert.assertNotNull(linkRepository.getByOrder(link1Order)); final JSONObject link2 = new JSONObject(); link2.put(Link.LINK_TITLE, "link title"); link2.put(Link.LINK_DESCRIPTION, "link description"); link2.put(Link.LINK_ADDRESS, "link address"); link2.put(Link.LINK_ORDER, link2Order); transaction = linkRepository.beginTransaction(); final String link2Id = linkRepository.add(link2); transaction.commit(); Assert.assertEquals(linkRepository.getMaxOrder(), link2Order); JSONObject link3 = new JSONObject(); link3.put(Link.LINK_TITLE, "link title"); link3.put(Link.LINK_DESCRIPTION, "link description"); link3.put(Link.LINK_ADDRESS, "link address"); link3.put(Link.LINK_ORDER, link3Order); transaction = linkRepository.beginTransaction(); linkRepository.add(link3); transaction.commit(); final int total = 3; Assert.assertEquals(linkRepository.count(), total); link1 = linkRepository.getUpper(link2Id); Assert.assertNotNull(link1); Assert.assertEquals(link1.getInt(Link.LINK_ORDER), link1Order); link3 = linkRepository.getUnder(link2Id); Assert.assertNotNull(link3); Assert.assertEquals(link3.getInt(Link.LINK_ORDER), link3Order); }
/** * Tests. * * @throws Exception exception */ @Test public void add() throws Exception { final UserRepository userRepository = getUserRepository(); final JSONObject another = new JSONObject(); another.put(User.USER_NAME, "test1"); another.put(User.USER_EMAIL, "*****@*****.**"); another.put(User.USER_PASSWORD, "pass1"); another.put(User.USER_ROLE, Role.DEFAULT_ROLE); another.put(UserExt.USER_ARTICLE_COUNT, 0); another.put(UserExt.USER_COMMENT_COUNT, 0); another.put(UserExt.USER_STATUS, "0"); Transaction transaction = userRepository.beginTransaction(); userRepository.add(another); transaction.commit(); Assert.assertNull(userRepository.getAdmin()); JSONObject admin = new JSONObject(); admin.put(User.USER_NAME, "test"); admin.put(User.USER_EMAIL, "*****@*****.**"); admin.put(User.USER_PASSWORD, "pass"); admin.put(User.USER_ROLE, Role.ADMIN_ROLE); admin.put(UserExt.USER_ARTICLE_COUNT, 1); admin.put(UserExt.USER_COMMENT_COUNT, 0); admin.put(UserExt.USER_STATUS, "0"); transaction = userRepository.beginTransaction(); userRepository.add(admin); transaction.commit(); Assert.assertTrue(userRepository.isAdminEmail("*****@*****.**")); Assert.assertFalse(userRepository.isAdminEmail("*****@*****.**")); admin = userRepository.getAdmin(); Assert.assertNotNull(admin); Assert.assertEquals(admin.optString(User.USER_NAME), "test"); Assert.assertEquals(admin.optInt(UserExt.USER_ARTICLE_COUNT), 1); final JSONObject result = userRepository.get( new Query() .setFilter(new PropertyFilter(User.USER_NAME, FilterOperator.EQUAL, "test1"))); final JSONArray users = result.getJSONArray(Keys.RESULTS); Assert.assertEquals(users.length(), 1); Assert.assertEquals(users.getJSONObject(0).getString(User.USER_EMAIL), "*****@*****.**"); final JSONObject notFound = userRepository.getByEmail("*****@*****.**"); Assert.assertNull(notFound); final JSONObject found = userRepository.getByEmail("*****@*****.**"); Assert.assertNotNull(found); Assert.assertEquals(found.getString(User.USER_PASSWORD), "pass1"); }
public void simpleGroupTest() { Group g = new Group(1L, "g1", null, false, null, null); assertEquals(g.getGroupId(), 1L); assertEquals(g.getGroupName(), "g1"); assertNull(g.getDescription()); assertFalse(g.isNewUserDefault()); assertNull(g.getRealm()); assertNull(g.getRealmAttributes()); }
@Test(groups = "slow", description = "Verify no PII data is required") public void testEmptyAccount() throws Exception { final Account emptyAccount = new Account(); final Account account = killBillClient.createAccount(emptyAccount, createdBy, reason, comment); Assert.assertNotNull(account.getExternalKey()); Assert.assertNull(account.getName()); Assert.assertNull(account.getEmail()); }
public void shouldSkipNulls() { modelMapper.createTypeMap(S1.class, D1.class).setPropertyCondition(Conditions.isNotNull()); S1 source = new S1(); D1 d = modelMapper.map(source, D1.class); assertEquals(d.longValue, Long.valueOf(4)); assertEquals(d.subSomething, 5); assertNull(d.sub); assertNull(d.nullString); }
@Test public void testGetTableHandle() { JdbcTableHandle tableHandle = metadata.getTableHandle(SESSION, new SchemaTableName("example", "numbers")); assertEquals( metadata.getTableHandle(SESSION, new SchemaTableName("example", "numbers")), tableHandle); assertNull(metadata.getTableHandle(SESSION, new SchemaTableName("example", "unknown"))); assertNull(metadata.getTableHandle(SESSION, new SchemaTableName("unknown", "numbers"))); assertNull(metadata.getTableHandle(SESSION, new SchemaTableName("unknown", "unknown"))); }
@Test public void testCallSucceedsWhenServiceUnavailable() throws ExecutionException, InterruptedException { client = newEventClient(Collections.<URI>emptyList()); client.post(new FixedDummyEventClass("host", new DateTime(), UUID.randomUUID(), 1, "foo")); assertNull(servlet.lastPath); assertNull(servlet.lastBody); }
@Test public void checkUnionNulls() { DoublesUnion union = new HeapDoublesUnion(128); DoublesSketch sk1 = union.getResultAndReset(); DoublesSketch sk2 = union.getResultAndReset(); assertNull(sk1); assertNull(sk2); union.update(sk2); DoublesSketch sk3 = union.getResultAndReset(); assertNull(sk3); }
@Test public void testNullEmpty() throws IOException { EvalFunc<String> func = new SketchToString("false"); Tuple dataTuple = null; String result = func.exec(dataTuple); assertNull(result); dataTuple = TupleFactory.getInstance().newTuple(0); result = func.exec(dataTuple); assertNull(result); }
public void testNoGenerations() { final BerkeleyDBTempTargetRepository targets = createTempTargetRepository(); try { assertNull(targets.getOldGeneration(0)); assertNull(targets.getNewGeneration(0)); assertFalse(targets.copyOldToNewGeneration(0, new ArrayList<Long>())); targets.nextGeneration(); } finally { targets.stop(); } }
public void testRemoveFromMainOwner() { Object k = getKeyForCache(0); cache(0).put(k, "0"); cache(0).remove(k, "1"); assertEquals(advancedCache(0).getDataContainer().get(k, null).getValue(), "0"); assertEquals(advancedCache(1).getDataContainer().get(k, null).getValue(), "0"); cache(0).remove(k, "0"); assertNull(advancedCache(0).getDataContainer().get(k, null)); assertNull(advancedCache(1).getDataContainer().get(k, null)); }