/** * Tests reading {@link ZNRecord} from {@link HelixPropertyStore}, where the {@link ZNRecord} has a map field * ({@link HelixAccountService#ACCOUNT_METADATA_MAP_KEY}: accountMap), and accountMap contains * ("accountId": badAccountJsonString). This is a NOT good {@link ZNRecord} format that should fail fetch or update. * @throws Exception Any unexpected exception. */ @Test public void testReadBadZNRecordCase5() throws Exception { Map<String, String> mapValue = new HashMap<>(); mapValue.put(String.valueOf(refAccount.getId()), BAD_ACCOUNT_METADATA_STRING); ZNRecord zNRecord = makeZNRecordWithMapField(null, ACCOUNT_METADATA_MAP_KEY, mapValue); updateAndWriteZNRecord(zNRecord, false); }
/** * Tests reading {@link ZNRecord} from {@link HelixPropertyStore}, where the {@link ZNRecord} has a map field * ({@link HelixAccountService#ACCOUNT_METADATA_MAP_KEY}: accountMap), and accountMap contains * ("accountId": accountJsonStr) that does not match. This is a NOT good {@link ZNRecord} format that should * fail fetch or update. * @throws Exception Any unexpected exception. */ @Test public void testReadBadZNRecordCase4() throws Exception { Map<String, String> mapValue = new HashMap<>(); mapValue.put("-1", refAccount.toJson(true).toString()); ZNRecord zNRecord = makeZNRecordWithMapField(null, ACCOUNT_METADATA_MAP_KEY, mapValue); updateAndWriteZNRecord(zNRecord, false); }
/** * Tests reading {@link ZNRecord} from {@link HelixPropertyStore}, where the {@link ZNRecord} is empty. This is a * good {@link ZNRecord} format that should NOT fail fetch or update. * @throws Exception Any unexpected exception. */ @Test public void testReadBadZNRecordCase1() throws Exception { ZNRecord zNRecord = makeZNRecordWithSimpleField(null, null, null); updateAndWriteZNRecord(zNRecord, true); }
/** * Tests reading {@link ZNRecord} from {@link HelixPropertyStore}, where the {@link ZNRecord} has an irrelevant * simple field ("key": "value"), but ("accountMetadata": someValidMap) is missing. This is a good {@link ZNRecord} * format that should NOT fail fetch or update. * @throws Exception Any unexpected exception. */ @Test public void testReadBadZNRecordCase2() throws Exception { ZNRecord zNRecord = makeZNRecordWithSimpleField(null, "key", "value"); updateAndWriteZNRecord(zNRecord, true); }
/** * Tests reading {@link ZNRecord} from {@link HelixPropertyStore}, where the {@link ZNRecord} has a map field * ("key": someValidAccountMap), but ({@link HelixAccountService#ACCOUNT_METADATA_MAP_KEY}: someValidMap) * is missing. This is a good {@link ZNRecord} format that should NOT fail fetch or update. * @throws Exception Any unexpected exception. */ @Test public void testReadBadZNRecordCase3() throws Exception { Map<String, String> mapValue = new HashMap<>(); mapValue.put(String.valueOf(refAccount.getId()), refAccount.toJson(true).toString()); ZNRecord zNRecord = makeZNRecordWithMapField(null, "key", mapValue); updateAndWriteZNRecord(zNRecord, true); }
/** * Tests reading {@link ZNRecord} from {@link HelixPropertyStore}, where the {@link ZNRecord} has an invalid account * record and a valid account record. This is a NOT good {@link ZNRecord} format and it should fail fetch or update * operations, with none of the record should be read. * @throws Exception Any unexpected exception. */ @Test public void testReadBadZNRecordCase6() throws Exception { ZNRecord zNRecord = new ZNRecord(String.valueOf(System.currentTimeMillis())); Map<String, String> accountMap = new HashMap<>(); accountMap.put(String.valueOf(refAccount.getId()), refAccount.toJson(true).toString()); accountMap.put(String.valueOf(refAccount.getId() + 1), BAD_ACCOUNT_METADATA_STRING); zNRecord.setMapField(ACCOUNT_METADATA_MAP_KEY, accountMap); updateAndWriteZNRecord(zNRecord, false); }