|
| 1 | +/** |
| 2 | + * Copyright (c) 2016 LARUS Business Automation [http://www.larus-ba.it] |
| 3 | + * <p> |
| 4 | + * This file is part of the "LARUS Integration Framework for Neo4j". |
| 5 | + * <p> |
| 6 | + * The "LARUS Integration Framework for Neo4j" is licensed |
| 7 | + * under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * <p> |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * <p> |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.neo4j.helpers.json.document.impl; |
| 21 | + |
| 22 | +import java.util.HashMap; |
| 23 | +import java.util.Map; |
| 24 | + |
| 25 | +import org.junit.Assert; |
| 26 | +import org.junit.Before; |
| 27 | +import org.junit.Test; |
| 28 | +import org.neo4j.helpers.json.document.DocumentId; |
| 29 | + |
| 30 | +public class DocumentIdBuilderPairTest { |
| 31 | + |
| 32 | + DocumentIdBuilderPair builder; |
| 33 | + |
| 34 | + @Before |
| 35 | + public void setUp() throws Exception { |
| 36 | + this.builder = new DocumentIdBuilderPair(); |
| 37 | + Map<String, String> conf = new HashMap<>(); |
| 38 | + conf.put("builder_id_pair_key1", "attribute"); |
| 39 | + conf.put("builder_id_pair_key2", "name"); |
| 40 | + this.builder.init(conf); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void testBuildId() { |
| 45 | + Map<String, Object> map = new HashMap<>(); |
| 46 | + map.put("attribute", 12); |
| 47 | + map.put("name", "artist"); |
| 48 | + DocumentId buildId = builder.buildId(map); |
| 49 | + Assert.assertEquals("attribute: 12, name: 'artist'", buildId.toCypherFilter()); |
| 50 | + } |
| 51 | + |
| 52 | + @Test(expected=NullPointerException.class) |
| 53 | + public void testBuildIdNoType() { |
| 54 | + Map<String, Object> map = new HashMap<>(); |
| 55 | + map.put("name", 12); |
| 56 | + builder.buildId(map); |
| 57 | + } |
| 58 | + |
| 59 | + @Test(expected=NullPointerException.class) |
| 60 | + public void testBuildIdNoId() { |
| 61 | + Map<String, Object> map = new HashMap<>(); |
| 62 | + map.put("attribute", "artist"); |
| 63 | + builder.buildId(map); |
| 64 | + } |
| 65 | +} |
0 commit comments